@kasufinance/kasu-sdk 1.0.4 → 2.2.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.
Files changed (84) hide show
  1. package/CLAUDE.md +410 -0
  2. package/README.md +179 -12
  3. package/dist/bundle.cjs.js +658 -90
  4. package/dist/bundle.esm.js +654 -92
  5. package/dist/facade/chain-configs.d.ts +11 -0
  6. package/dist/facade/chain-configs.js +84 -0
  7. package/dist/facade/chain-configs.js.map +1 -0
  8. package/dist/facade/deposits.d.ts +56 -0
  9. package/dist/facade/deposits.js +87 -0
  10. package/dist/facade/deposits.js.map +1 -0
  11. package/dist/facade/index.d.ts +6 -0
  12. package/dist/facade/index.js +9 -0
  13. package/dist/facade/index.js.map +1 -0
  14. package/dist/facade/kasu.d.ts +71 -0
  15. package/dist/facade/kasu.js +101 -0
  16. package/dist/facade/kasu.js.map +1 -0
  17. package/dist/facade/strategies.d.ts +37 -0
  18. package/dist/facade/strategies.js +112 -0
  19. package/dist/facade/strategies.js.map +1 -0
  20. package/dist/facade/types.d.ts +127 -0
  21. package/dist/facade/types.js +2 -0
  22. package/dist/facade/types.js.map +1 -0
  23. package/dist/facade/user-portfolio.d.ts +35 -0
  24. package/dist/facade/user-portfolio.js +53 -0
  25. package/dist/facade/user-portfolio.js.map +1 -0
  26. package/dist/index.d.ts +9 -17
  27. package/dist/index.js +9 -16
  28. package/dist/index.js.map +1 -1
  29. package/dist/kasu-sdk.d.ts +17 -0
  30. package/dist/kasu-sdk.js +17 -0
  31. package/dist/kasu-sdk.js.map +1 -0
  32. package/dist/sdk-config.d.ts +34 -4
  33. package/dist/sdk-config.js +9 -6
  34. package/dist/sdk-config.js.map +1 -1
  35. package/dist/services/DataService/data-service.d.ts +9 -2
  36. package/dist/services/DataService/data-service.js +91 -53
  37. package/dist/services/DataService/data-service.js.map +1 -1
  38. package/dist/services/DataService/queries.d.ts +0 -1
  39. package/dist/services/DataService/queries.js +0 -8
  40. package/dist/services/DataService/queries.js.map +1 -1
  41. package/dist/services/DataService/subgraph-types.d.ts +0 -6
  42. package/dist/services/DataService/types.d.ts +0 -1
  43. package/dist/services/Locking/locking.d.ts +9 -3
  44. package/dist/services/Locking/locking.js +114 -20
  45. package/dist/services/Locking/locking.js.map +1 -1
  46. package/dist/services/Locking/types.d.ts +1 -1
  47. package/dist/services/Portfolio/portfolio.d.ts +3 -2
  48. package/dist/services/Portfolio/portfolio.js +15 -7
  49. package/dist/services/Portfolio/portfolio.js.map +1 -1
  50. package/dist/services/Portfolio/types.d.ts +2 -2
  51. package/dist/services/UserLending/user-lending.d.ts +3 -1
  52. package/dist/services/UserLending/user-lending.js +9 -3
  53. package/dist/services/UserLending/user-lending.js.map +1 -1
  54. package/dist/tests/facade.test.d.ts +1 -0
  55. package/dist/tests/facade.test.js +196 -0
  56. package/dist/tests/facade.test.js.map +1 -0
  57. package/dist/tests/sample.test.js +19 -14
  58. package/dist/tests/sample.test.js.map +1 -1
  59. package/dist/utils/deployment-mode.d.ts +6 -0
  60. package/dist/utils/deployment-mode.js +8 -0
  61. package/dist/utils/deployment-mode.js.map +1 -0
  62. package/package.json +2 -2
  63. package/src/facade/chain-configs.ts +93 -0
  64. package/src/facade/deposits.ts +102 -0
  65. package/src/facade/index.ts +26 -0
  66. package/src/facade/kasu.ts +144 -0
  67. package/src/facade/strategies.ts +119 -0
  68. package/src/facade/types.ts +168 -0
  69. package/src/facade/user-portfolio.ts +73 -0
  70. package/src/index.ts +59 -25
  71. package/src/kasu-sdk.ts +27 -0
  72. package/src/sdk-config.ts +43 -15
  73. package/src/services/DataService/data-service.ts +106 -66
  74. package/src/services/DataService/queries.ts +0 -9
  75. package/src/services/DataService/subgraph-types.ts +0 -7
  76. package/src/services/DataService/types.ts +0 -1
  77. package/src/services/Locking/locking.ts +141 -25
  78. package/src/services/Locking/types.ts +1 -1
  79. package/src/services/Portfolio/portfolio.ts +21 -11
  80. package/src/services/Portfolio/types.ts +2 -2
  81. package/src/services/UserLending/user-lending.ts +13 -4
  82. package/src/tests/facade.test.ts +245 -0
  83. package/src/tests/sample.test.ts +7 -9
  84. package/src/utils/deployment-mode.ts +9 -0
@@ -0,0 +1,127 @@
1
+ import { BigNumberish, BytesLike } from 'ethers';
2
+ import { ContractAddresses, SdkConfigOptions } from '../sdk-config';
3
+ import { LendingTotals, PoolOverview, TrancheData } from '../services/DataService/types';
4
+ import { PortfolioLendingPool, PortfolioSummary } from '../services/Portfolio/types';
5
+ export type SupportedChain = 'base' | 'xdc' | 'plume';
6
+ export interface ChainConfigEntry {
7
+ chainId: number;
8
+ name: string;
9
+ isLiteDeployment: boolean;
10
+ contracts: ContractAddresses;
11
+ subgraphUrl: string;
12
+ directusUrl: string;
13
+ unusedPoolIds: string[];
14
+ poolMetadataMapping?: Record<string, string>;
15
+ }
16
+ /** Options passed to `Kasu.create()`. */
17
+ export interface KasuOptions {
18
+ /** A supported chain name or a custom `ChainConfigEntry`. */
19
+ chain: SupportedChain | ChainConfigEntry;
20
+ /** ethers Signer (for transactions) or Provider (read-only). */
21
+ signerOrProvider: import('ethers').Signer | import('@ethersproject/providers').Provider;
22
+ /** Override any default config value. */
23
+ configOverrides?: Partial<SdkConfigOptions>;
24
+ }
25
+ export interface Strategy {
26
+ id: string;
27
+ name: string;
28
+ description: string;
29
+ isActive: boolean;
30
+ /** Weighted-average APY across tranches (decimal, e.g. 0.08 = 8 %). */
31
+ apy: number;
32
+ tvl: {
33
+ /** On-chain + off-chain total. */
34
+ total: string;
35
+ offchain: string;
36
+ };
37
+ /** Remaining capacity across all tranches. */
38
+ availableCapacity: string;
39
+ /** 0-1 utilisation ratio. */
40
+ capacityUtilisation: string;
41
+ tranches: StrategyTranche[];
42
+ /** Asset class label (e.g. "Tax Receivables"). */
43
+ assetClass: string;
44
+ /** Fixed or Variable. */
45
+ apyStructure: 'Variable' | 'Fixed';
46
+ /** Thumbnail image URL (empty string when Directus unavailable). */
47
+ thumbnailUrl: string;
48
+ /** Banner image URL (empty string when Directus unavailable). */
49
+ bannerUrl: string;
50
+ /** Raw `PoolOverview` for power-users who need all fields. */
51
+ _raw: PoolOverview;
52
+ }
53
+ export interface StrategyTranche {
54
+ id: string;
55
+ name: string;
56
+ /** Current base APY (decimal). */
57
+ apy: number;
58
+ minApy: number;
59
+ maxApy: number;
60
+ /** Minimum deposit in stable asset units (ether-formatted string). */
61
+ minimumDeposit: string;
62
+ /** Maximum deposit in stable asset units (ether-formatted string). */
63
+ maximumDeposit: string;
64
+ /** Remaining tranche capacity (ether-formatted string). */
65
+ availableCapacity: string;
66
+ /** Fixed-term deposit options on this tranche. */
67
+ fixedTermOptions: FixedTermOption[];
68
+ /** Raw `TrancheData` for power-users. */
69
+ _raw: TrancheData;
70
+ }
71
+ export interface FixedTermOption {
72
+ configId: string;
73
+ /** Annual APY (decimal). */
74
+ apy: number;
75
+ /** Lock duration in epochs (1 epoch ≈ 1 week). */
76
+ epochLockDuration: string;
77
+ }
78
+ export interface DepositParams {
79
+ poolId: string;
80
+ trancheId: string;
81
+ /** Amount in stable asset base units (BigNumberish). */
82
+ amount: BigNumberish;
83
+ /** KYC signature obtained from the Nexera flow. */
84
+ kycSignature: {
85
+ blockExpiration: BigNumberish;
86
+ signature: BytesLike;
87
+ };
88
+ /** ABI-encoded deposit data (contract acceptance). Pass `'0x'` when not needed. */
89
+ depositData?: BytesLike;
90
+ /** Fixed-term config ID. Pass `0` for variable deposits. */
91
+ fixedTermConfigId?: BigNumberish;
92
+ /** Swap calldata. Pass `'0x'` when depositing the stable asset directly. */
93
+ swapData?: BytesLike;
94
+ /** Native token value to send (e.g. for gas on some chains). Defaults to `'0'`. */
95
+ ethValue?: string;
96
+ }
97
+ export interface WithdrawParams {
98
+ poolId: string;
99
+ trancheId: string;
100
+ /** Stable asset amount to withdraw, or `'max'` to withdraw entire balance. */
101
+ amount: BigNumberish;
102
+ /** Required when `amount` is `'max'`. */
103
+ userAddress?: string;
104
+ }
105
+ export interface DepositLimits {
106
+ /** Minimum deposit (ether-formatted stable asset amount). */
107
+ min: string;
108
+ /** Maximum deposit (ether-formatted stable asset amount). */
109
+ max: string;
110
+ /** Remaining tranche capacity (ether-formatted stable asset amount). */
111
+ availableCapacity: string;
112
+ }
113
+ export interface KycParams {
114
+ contractAbi: any;
115
+ contractAddress: string;
116
+ functionName: string;
117
+ args: BytesLike[];
118
+ userAddress: string;
119
+ chainId: string;
120
+ }
121
+ export interface UserPositions {
122
+ /** Per-pool breakdown. */
123
+ pools: PortfolioLendingPool[];
124
+ /** Aggregate summary (invested, yields, APY). */
125
+ summary: PortfolioSummary;
126
+ }
127
+ export type PlatformStats = LendingTotals;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/facade/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { Provider } from '@ethersproject/providers';
2
+ import { DataService } from '../services/DataService/data-service';
3
+ import { Portfolio } from '../services/Portfolio/portfolio';
4
+ import { UserRequest } from '../services/UserLending/types';
5
+ import { UserLending } from '../services/UserLending/user-lending';
6
+ import { UserPositions } from './types';
7
+ /**
8
+ * High-level facade for querying a user's portfolio, positions, and history.
9
+ *
10
+ * Orchestrates DataService, UserLending, and Portfolio services so the caller
11
+ * only needs to provide a wallet address.
12
+ */
13
+ export declare class PortfolioFacade {
14
+ private _dataService;
15
+ private _userLending;
16
+ private _portfolio;
17
+ constructor(_dataService: DataService, _userLending: UserLending, _portfolio: Portfolio);
18
+ /**
19
+ * Fetch a user's complete portfolio: per-pool positions and aggregate summary.
20
+ *
21
+ * ```ts
22
+ * const positions = await kasu.portfolio.getPositions('0xUser...');
23
+ * console.log(positions.summary.current.totalLendingPoolInvestments);
24
+ * ```
25
+ *
26
+ * @param userAddress - Wallet address.
27
+ * @param provider - Optional separate provider for balance queries (useful when the
28
+ * SDK was initialised with a Signer but you need a read-only provider).
29
+ */
30
+ getPositions(userAddress: string, provider?: Provider): Promise<UserPositions>;
31
+ /**
32
+ * Fetch a user's full transaction history (deposits, withdrawals, cancellations).
33
+ */
34
+ getTransactionHistory(userAddress: `0x${string}`): Promise<UserRequest[]>;
35
+ }
@@ -0,0 +1,53 @@
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
+ /**
11
+ * High-level facade for querying a user's portfolio, positions, and history.
12
+ *
13
+ * Orchestrates DataService, UserLending, and Portfolio services so the caller
14
+ * only needs to provide a wallet address.
15
+ */
16
+ export class PortfolioFacade {
17
+ constructor(_dataService, _userLending, _portfolio) {
18
+ this._dataService = _dataService;
19
+ this._userLending = _userLending;
20
+ this._portfolio = _portfolio;
21
+ }
22
+ /**
23
+ * Fetch a user's complete portfolio: per-pool positions and aggregate summary.
24
+ *
25
+ * ```ts
26
+ * const positions = await kasu.portfolio.getPositions('0xUser...');
27
+ * console.log(positions.summary.current.totalLendingPoolInvestments);
28
+ * ```
29
+ *
30
+ * @param userAddress - Wallet address.
31
+ * @param provider - Optional separate provider for balance queries (useful when the
32
+ * SDK was initialised with a Signer but you need a read-only provider).
33
+ */
34
+ getPositions(userAddress, provider) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const currentEpoch = yield this._userLending.getCurrentEpoch();
37
+ const poolOverviews = yield this._dataService.getPoolOverview(currentEpoch);
38
+ const pools = yield this._portfolio.getPortfolioLendingData(userAddress, poolOverviews, currentEpoch, provider);
39
+ const summary = yield this._portfolio.getPortfolioSummary(userAddress, pools, currentEpoch);
40
+ return { pools, summary };
41
+ });
42
+ }
43
+ /**
44
+ * Fetch a user's full transaction history (deposits, withdrawals, cancellations).
45
+ */
46
+ getTransactionHistory(userAddress) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const currentEpoch = yield this._userLending.getCurrentEpoch();
49
+ return yield this._userLending.getUserRequests(userAddress, currentEpoch);
50
+ });
51
+ }
52
+ }
53
+ //# sourceMappingURL=user-portfolio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-portfolio.js","sourceRoot":"","sources":["../../src/facade/user-portfolio.ts"],"names":[],"mappings":";;;;;;;;;AASA;;;;;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,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,CACzD,YAAY,CACf,CAAC;YAEF,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;;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;CACJ"}
package/dist/index.d.ts CHANGED
@@ -1,17 +1,9 @@
1
- import { Provider } from '@ethersproject/providers';
2
- import { Signer } from 'ethers';
3
- import { SdkConfig } from './sdk-config';
4
- import { DataService } from './services/DataService/data-service';
5
- import { KSULocking } from './services/Locking/locking';
6
- import { Portfolio } from './services/Portfolio/portfolio';
7
- import { Swapper } from './services/Swapper/swapper';
8
- import { UserLending } from './services/UserLending/user-lending';
9
- export declare class KasuSdk {
10
- private readonly _graphClient;
11
- readonly Locking: KSULocking;
12
- readonly DataService: DataService;
13
- readonly UserLending: UserLending;
14
- readonly Portfolio: Portfolio;
15
- readonly Swapper: Swapper;
16
- constructor(config: SdkConfig, signerOrProvider: Provider | Signer);
17
- }
1
+ export { KasuSdk } from './kasu-sdk';
2
+ export type { ContractAddresses, SdkConfigOptions } from './sdk-config';
3
+ export { SdkConfig } from './sdk-config';
4
+ export type { PoolOverview, TrancheData, LendingTotals, PoolRepayment, RiskManagement, PoolDelegateProfileAndHistory, PoolTranche, PoolCreditMetrics, BadAndDoubtfulDebts, FinancialReportingDocuments, } from './services/DataService/types';
5
+ export type { UserRequest, UserRequestEvent, UserTrancheBalance, UserPoolBalance, UserApyBonus, PortfolioUserTrancheBalance, } from './services/UserLending/types';
6
+ export type { PortfolioSummary, PortfolioLendingPool, PortfolioTranche, PortfolioRewards, PortfolioTrancheDepositDetails, } from './services/Portfolio/types';
7
+ export type { UserLock, UserBonusData, LockPeriod, GQLGetLockingPeriods, SystemVariables, } from './services/Locking/types';
8
+ export type { PoolOverviewDirectus, PlatformOverviewDirectus, } from './services/DataService/directus-types';
9
+ export * from './facade';
package/dist/index.js CHANGED
@@ -1,17 +1,10 @@
1
- import { GraphQLClient } from 'graphql-request';
2
- import { DataService } from './services/DataService/data-service';
3
- import { KSULocking } from './services/Locking/locking';
4
- import { Portfolio } from './services/Portfolio/portfolio';
5
- import { Swapper } from './services/Swapper/swapper';
6
- import { UserLending } from './services/UserLending/user-lending';
7
- export class KasuSdk {
8
- constructor(config, signerOrProvider) {
9
- this._graphClient = new GraphQLClient(config.subgraphUrl);
10
- this.Locking = new KSULocking(config, signerOrProvider);
11
- this.UserLending = new UserLending(config, signerOrProvider);
12
- this.DataService = new DataService(config, signerOrProvider);
13
- this.Portfolio = new Portfolio(config, signerOrProvider);
14
- this.Swapper = new Swapper();
15
- }
16
- }
1
+ // ---------------------------------------------------------------------------
2
+ // Core SDK class (low-level service access)
3
+ // ---------------------------------------------------------------------------
4
+ export { KasuSdk } from './kasu-sdk';
5
+ export { SdkConfig } from './sdk-config';
6
+ // ---------------------------------------------------------------------------
7
+ // Re-export facade (high-level integrator API)
8
+ // ---------------------------------------------------------------------------
9
+ export * from './facade';
17
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,MAAM,OAAO,OAAO;IAOhB,YAAY,MAAiB,EAAE,gBAAmC;QAC9D,IAAI,CAAC,YAAY,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACxD,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACzD,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IACjC,CAAC;CACJ"}
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;AAgDzC,8EAA8E;AAC9E,+CAA+C;AAC/C,8EAA8E;AAC9E,cAAc,UAAU,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Provider } from '@ethersproject/providers';
2
+ import { Signer } from 'ethers';
3
+ import { SdkConfig } from './sdk-config';
4
+ import { DataService } from './services/DataService/data-service';
5
+ import { KSULocking } from './services/Locking/locking';
6
+ import { Portfolio } from './services/Portfolio/portfolio';
7
+ import { Swapper } from './services/Swapper/swapper';
8
+ import { UserLending } from './services/UserLending/user-lending';
9
+ export declare class KasuSdk {
10
+ private readonly _graphClient;
11
+ readonly Locking: KSULocking;
12
+ readonly DataService: DataService;
13
+ readonly UserLending: UserLending;
14
+ readonly Portfolio: Portfolio;
15
+ readonly Swapper: Swapper;
16
+ constructor(config: SdkConfig, signerOrProvider: Provider | Signer);
17
+ }
@@ -0,0 +1,17 @@
1
+ import { GraphQLClient } from 'graphql-request';
2
+ import { DataService } from './services/DataService/data-service';
3
+ import { KSULocking } from './services/Locking/locking';
4
+ import { Portfolio } from './services/Portfolio/portfolio';
5
+ import { Swapper } from './services/Swapper/swapper';
6
+ import { UserLending } from './services/UserLending/user-lending';
7
+ export class KasuSdk {
8
+ constructor(config, signerOrProvider) {
9
+ this._graphClient = new GraphQLClient(config.subgraphUrl);
10
+ this.Locking = new KSULocking(config, signerOrProvider);
11
+ this.UserLending = new UserLending(config, signerOrProvider);
12
+ this.DataService = new DataService(config, signerOrProvider);
13
+ this.Portfolio = new Portfolio(config, signerOrProvider);
14
+ this.Swapper = new Swapper();
15
+ }
16
+ }
17
+ //# sourceMappingURL=kasu-sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kasu-sdk.js","sourceRoot":"","sources":["../src/kasu-sdk.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,MAAM,OAAO,OAAO;IAOhB,YAAY,MAAiB,EAAE,gBAAmC;QAC9D,IAAI,CAAC,YAAY,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACxD,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACzD,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IACjC,CAAC;CACJ"}
@@ -1,5 +1,6 @@
1
1
  export interface ContractAddresses {
2
- KSUToken: string;
2
+ /** KSU Token address - only present on Full deployments (Base), undefined on Lite (XDC, Plume) */
3
+ KSUToken?: string;
3
4
  IKSULocking: string;
4
5
  IKSULockBonus: string;
5
6
  UserManager: string;
@@ -9,14 +10,43 @@ export interface ContractAddresses {
9
10
  UserLoyaltyRewards: string;
10
11
  KsuPrice: string;
11
12
  ClearingCoordinator: string;
12
- KasuNFTs: string;
13
+ /** KasuNFTs address - only present on Full deployments */
14
+ KasuNFTs?: string;
13
15
  ExternalTVL: string;
14
16
  }
17
+ export interface SdkConfigOptions {
18
+ subgraphUrl: string;
19
+ contracts: ContractAddresses;
20
+ /** Directus CMS URL. Optional – when omitted, pool descriptions/images will not be available but on-chain data still works. */
21
+ directusUrl?: string;
22
+ UNUSED_LENDING_POOL_IDS: string[];
23
+ /**
24
+ * Whether this is a Lite deployment (no KSU token, locking, or loyalty features).
25
+ * Set to true for XDC, Plume, and other chains without the full token system.
26
+ * @default false
27
+ */
28
+ isLiteDeployment?: boolean;
29
+ /**
30
+ * Maps pool addresses to their metadata source pool address in Directus.
31
+ * Used for chains (XDC, Plume) that share pool descriptions with Base.
32
+ * Key: pool address on this chain (lowercase)
33
+ * Value: pool address in Directus / Base pool (lowercase)
34
+ */
35
+ poolMetadataMapping?: Record<string, string>;
36
+ /**
37
+ * Decimals of the stable asset used by lending pools (e.g. 6 for USDC/AUDD).
38
+ * @default 6
39
+ */
40
+ stableAssetDecimals?: number;
41
+ }
15
42
  export declare class SdkConfig {
16
43
  subgraphUrl: string;
17
- plumeSubgraphUrl: string;
18
44
  contracts: ContractAddresses;
45
+ /** Directus CMS URL. When empty, DataService skips CMS enrichment and returns on-chain data only. */
19
46
  directusUrl: string;
20
47
  UNUSED_LENDING_POOL_IDS: string[];
21
- constructor(subgraphUrl: string, plumeSubgraphUrl: string, contracts: ContractAddresses, directusUrl: string, UNUSED_LENDING_POOL_IDS: string[]);
48
+ isLiteDeployment: boolean;
49
+ poolMetadataMapping: Record<string, string>;
50
+ stableAssetDecimals: number;
51
+ constructor(options: SdkConfigOptions);
22
52
  }
@@ -1,10 +1,13 @@
1
1
  export class SdkConfig {
2
- constructor(subgraphUrl, plumeSubgraphUrl, contracts, directusUrl, UNUSED_LENDING_POOL_IDS) {
3
- this.subgraphUrl = subgraphUrl;
4
- this.plumeSubgraphUrl = plumeSubgraphUrl;
5
- this.contracts = contracts;
6
- this.directusUrl = directusUrl;
7
- this.UNUSED_LENDING_POOL_IDS = UNUSED_LENDING_POOL_IDS;
2
+ constructor(options) {
3
+ var _a, _b, _c, _d;
4
+ this.subgraphUrl = options.subgraphUrl;
5
+ this.contracts = options.contracts;
6
+ this.directusUrl = (_a = options.directusUrl) !== null && _a !== void 0 ? _a : '';
7
+ this.UNUSED_LENDING_POOL_IDS = options.UNUSED_LENDING_POOL_IDS;
8
+ this.isLiteDeployment = (_b = options.isLiteDeployment) !== null && _b !== void 0 ? _b : false;
9
+ this.poolMetadataMapping = (_c = options.poolMetadataMapping) !== null && _c !== void 0 ? _c : {};
10
+ this.stableAssetDecimals = (_d = options.stableAssetDecimals) !== null && _d !== void 0 ? _d : 6;
8
11
  }
9
12
  }
10
13
  //# sourceMappingURL=sdk-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-config.js","sourceRoot":"","sources":["../src/sdk-config.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,SAAS;IAOlB,YACI,WAAmB,EACnB,gBAAwB,EACxB,SAA4B,EAC5B,WAAmB,EACnB,uBAAiC;QAEjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;IAC3D,CAAC;CACJ"}
1
+ {"version":3,"file":"sdk-config.js","sourceRoot":"","sources":["../src/sdk-config.ts"],"names":[],"mappings":"AA2CA,MAAM,OAAO,SAAS;IAUlB,YAAY,OAAyB;;QACjC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,MAAA,OAAO,CAAC,WAAW,mCAAI,EAAE,CAAC;QAC7C,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;QAC/D,IAAI,CAAC,gBAAgB,GAAG,MAAA,OAAO,CAAC,gBAAgB,mCAAI,KAAK,CAAC;QAC1D,IAAI,CAAC,mBAAmB,GAAG,MAAA,OAAO,CAAC,mBAAmB,mCAAI,EAAE,CAAC;QAC7D,IAAI,CAAC,mBAAmB,GAAG,MAAA,OAAO,CAAC,mBAAmB,mCAAI,CAAC,CAAC;IAChE,CAAC;CACJ"}
@@ -7,13 +7,20 @@ import { BadAndDoubtfulDebts, FinancialReportingDocuments, LendingTotals, PoolCr
7
7
  export declare class DataService {
8
8
  private _kasuConfig;
9
9
  private readonly _graph;
10
- private readonly _plumeGraph;
11
10
  private readonly _externalTvlAbi;
12
11
  private readonly _directus;
13
12
  private _directusPoolOverview;
14
- private _plumeTvl;
15
13
  constructor(_kasuConfig: SdkConfig, signerOrProvider: Signer | Provider);
16
14
  private getUrlFromFile;
15
+ /**
16
+ * Maps a pool ID to its metadata source pool ID.
17
+ * Used for chains (XDC, Plume) that share Directus metadata with Base pools.
18
+ */
19
+ private getMetadataPoolId;
20
+ /**
21
+ * Maps an array of pool IDs to their metadata source pool IDs.
22
+ */
23
+ private getMetadataPoolIds;
17
24
  calculatePoolCapacity(poolCapacities: number[], poolCapacityPercentages: number[], index: number, spillOver: number, lendingPoolSubgraph: LendingPoolSubgraph, lendingPoolConfig: LendingPoolConfigurationSubgraph): {
18
25
  poolCapacity: number[];
19
26
  poolCapacityPercentage: number[];