@kasufinance/kasu-sdk 2.4.2 → 2.6.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 (180) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +201 -253
  3. package/dist/bundle.cjs.js +5472 -1710
  4. package/dist/bundle.esm.js +5415 -1713
  5. package/dist/domain/au-minimum.d.ts +135 -0
  6. package/dist/domain/au-minimum.js +154 -0
  7. package/dist/domain/au-minimum.js.map +1 -0
  8. package/dist/domain/au-minimum.test.js +202 -0
  9. package/dist/domain/au-minimum.test.js.map +1 -0
  10. package/dist/domain/deposit-bounds.d.ts +62 -0
  11. package/dist/domain/deposit-bounds.js +84 -0
  12. package/dist/domain/deposit-bounds.js.map +1 -0
  13. package/dist/domain/deposit-bounds.test.d.ts +1 -0
  14. package/dist/domain/deposit-bounds.test.js +135 -0
  15. package/dist/domain/deposit-bounds.test.js.map +1 -0
  16. package/dist/domain/index.d.ts +40 -0
  17. package/dist/domain/index.js +33 -0
  18. package/dist/domain/index.js.map +1 -0
  19. package/dist/domain/loan-contract.d.ts +174 -0
  20. package/dist/domain/loan-contract.js +160 -0
  21. package/dist/domain/loan-contract.js.map +1 -0
  22. package/dist/domain/loan-contract.test.d.ts +1 -0
  23. package/dist/domain/loan-contract.test.js +255 -0
  24. package/dist/domain/loan-contract.test.js.map +1 -0
  25. package/dist/domain/partners.d.ts +34 -0
  26. package/dist/domain/partners.js +43 -0
  27. package/dist/domain/partners.js.map +1 -0
  28. package/dist/domain/partners.test.d.ts +1 -0
  29. package/dist/domain/partners.test.js +53 -0
  30. package/dist/domain/partners.test.js.map +1 -0
  31. package/dist/domain/pools.d.ts +70 -0
  32. package/dist/domain/pools.js +134 -0
  33. package/dist/domain/pools.js.map +1 -0
  34. package/dist/domain/pools.test.d.ts +1 -0
  35. package/dist/domain/pools.test.js +184 -0
  36. package/dist/domain/pools.test.js.map +1 -0
  37. package/dist/domain/rates.d.ts +83 -0
  38. package/dist/domain/rates.js +120 -0
  39. package/dist/domain/rates.js.map +1 -0
  40. package/dist/domain/rates.test.d.ts +1 -0
  41. package/dist/domain/rates.test.js +181 -0
  42. package/dist/domain/rates.test.js.map +1 -0
  43. package/dist/domain/requests.d.ts +181 -0
  44. package/dist/domain/requests.js +202 -0
  45. package/dist/domain/requests.js.map +1 -0
  46. package/dist/domain/requests.test.d.ts +1 -0
  47. package/dist/domain/requests.test.js +470 -0
  48. package/dist/domain/requests.test.js.map +1 -0
  49. package/dist/domain/settlement.d.ts +97 -0
  50. package/dist/domain/settlement.js +117 -0
  51. package/dist/domain/settlement.js.map +1 -0
  52. package/dist/domain/settlement.test.d.ts +1 -0
  53. package/dist/domain/settlement.test.js +152 -0
  54. package/dist/domain/settlement.test.js.map +1 -0
  55. package/dist/domain/tranche-display-name.d.ts +17 -0
  56. package/dist/domain/tranche-display-name.js +30 -0
  57. package/dist/domain/tranche-display-name.js.map +1 -0
  58. package/dist/domain/tranche-display-name.test.d.ts +1 -0
  59. package/dist/domain/tranche-display-name.test.js +58 -0
  60. package/dist/domain/tranche-display-name.test.js.map +1 -0
  61. package/dist/domain/tranches.d.ts +89 -0
  62. package/dist/domain/tranches.js +150 -0
  63. package/dist/domain/tranches.js.map +1 -0
  64. package/dist/domain/tranches.test.d.ts +1 -0
  65. package/dist/domain/tranches.test.js +206 -0
  66. package/dist/domain/tranches.test.js.map +1 -0
  67. package/dist/domain/wallet-errors.d.ts +37 -0
  68. package/dist/domain/wallet-errors.js +56 -0
  69. package/dist/domain/wallet-errors.js.map +1 -0
  70. package/dist/domain/wallet-errors.test.d.ts +1 -0
  71. package/dist/domain/wallet-errors.test.js +71 -0
  72. package/dist/domain/wallet-errors.test.js.map +1 -0
  73. package/dist/facade/chain-configs.js +61 -1
  74. package/dist/facade/chain-configs.js.map +1 -1
  75. package/dist/facade/config.test.d.ts +1 -0
  76. package/dist/facade/config.test.js +216 -0
  77. package/dist/facade/config.test.js.map +1 -0
  78. package/dist/facade/deposits.d.ts +22 -1
  79. package/dist/facade/deposits.js +24 -1
  80. package/dist/facade/deposits.js.map +1 -1
  81. package/dist/facade/facade.test.d.ts +1 -0
  82. package/dist/{tests → facade}/facade.test.js +87 -5
  83. package/dist/facade/facade.test.js.map +1 -0
  84. package/dist/facade/index.d.ts +2 -1
  85. package/dist/facade/index.js +2 -0
  86. package/dist/facade/index.js.map +1 -1
  87. package/dist/facade/kasu.d.ts +49 -8
  88. package/dist/facade/kasu.js +117 -13
  89. package/dist/facade/kasu.js.map +1 -1
  90. package/dist/facade/strategies.d.ts +25 -0
  91. package/dist/facade/strategies.js +36 -0
  92. package/dist/facade/strategies.js.map +1 -1
  93. package/dist/facade/types.d.ts +57 -2
  94. package/dist/facade/unused-pool-ids.d.ts +31 -0
  95. package/dist/facade/unused-pool-ids.js +57 -0
  96. package/dist/facade/unused-pool-ids.js.map +1 -0
  97. package/dist/facade/user-portfolio.d.ts +18 -0
  98. package/dist/facade/user-portfolio.js +23 -0
  99. package/dist/facade/user-portfolio.js.map +1 -1
  100. package/dist/index.d.ts +2 -0
  101. package/dist/index.js +6 -0
  102. package/dist/index.js.map +1 -1
  103. package/dist/sdk-config.d.ts +11 -0
  104. package/dist/sdk-config.js +8 -1
  105. package/dist/sdk-config.js.map +1 -1
  106. package/dist/services/DataService/data-service.d.ts +5 -0
  107. package/dist/services/DataService/data-service.js +10 -12
  108. package/dist/services/DataService/data-service.js.map +1 -1
  109. package/dist/services/DataService/directus-client.d.ts +26 -0
  110. package/dist/services/DataService/directus-client.js +38 -0
  111. package/dist/services/DataService/directus-client.js.map +1 -0
  112. package/dist/services/Locking/calculate-apy.test.d.ts +1 -0
  113. package/dist/services/Locking/calculate-apy.test.js +41 -0
  114. package/dist/services/Locking/calculate-apy.test.js.map +1 -0
  115. package/dist/services/Locking/locking.d.ts +14 -0
  116. package/dist/services/Locking/locking.js +16 -2
  117. package/dist/services/Locking/locking.js.map +1 -1
  118. package/dist/services/UserLending/user-lending.js +11 -7
  119. package/dist/services/UserLending/user-lending.js.map +1 -1
  120. package/dist/tests/sample.test.js +46 -25
  121. package/dist/tests/sample.test.js.map +1 -1
  122. package/package.json +43 -12
  123. package/src/domain/au-minimum.test.ts +371 -0
  124. package/src/domain/au-minimum.ts +192 -0
  125. package/src/domain/deposit-bounds.test.ts +200 -0
  126. package/src/domain/deposit-bounds.ts +118 -0
  127. package/src/domain/index.ts +134 -0
  128. package/src/domain/loan-contract.test.ts +343 -0
  129. package/src/domain/loan-contract.ts +275 -0
  130. package/src/domain/partners.test.ts +83 -0
  131. package/src/domain/partners.ts +66 -0
  132. package/src/domain/pools.test.ts +260 -0
  133. package/src/domain/pools.ts +150 -0
  134. package/src/domain/rates.test.ts +254 -0
  135. package/src/domain/rates.ts +120 -0
  136. package/src/domain/requests.test.ts +653 -0
  137. package/src/domain/requests.ts +414 -0
  138. package/src/domain/settlement.test.ts +198 -0
  139. package/src/domain/settlement.ts +161 -0
  140. package/src/domain/tranche-display-name.test.ts +96 -0
  141. package/src/domain/tranche-display-name.ts +34 -0
  142. package/src/domain/tranches.test.ts +300 -0
  143. package/src/domain/tranches.ts +177 -0
  144. package/src/domain/wallet-errors.test.ts +100 -0
  145. package/src/domain/wallet-errors.ts +56 -0
  146. package/src/facade/chain-configs.ts +62 -1
  147. package/src/facade/config.test.ts +265 -0
  148. package/src/facade/deposits.ts +25 -0
  149. package/src/{tests → facade}/facade.test.ts +134 -5
  150. package/src/facade/index.ts +4 -0
  151. package/src/facade/kasu.ts +155 -12
  152. package/src/facade/strategies.ts +36 -0
  153. package/src/facade/types.ts +60 -2
  154. package/src/facade/unused-pool-ids.ts +59 -0
  155. package/src/facade/user-portfolio.ts +24 -0
  156. package/src/index.ts +8 -0
  157. package/src/sdk-config.ts +19 -1
  158. package/src/services/DataService/data-service.ts +14 -26
  159. package/src/services/DataService/directus-client.ts +54 -0
  160. package/src/services/Locking/calculate-apy.test.ts +52 -0
  161. package/src/services/Locking/locking.ts +16 -2
  162. package/src/services/UserLending/user-lending.ts +17 -21
  163. package/src/tests/sample.test.ts +54 -33
  164. package/.eslintignore +0 -3
  165. package/.eslintrc.json +0 -90
  166. package/.github/workflows/ci.yml +0 -39
  167. package/.github/workflows/gitleaks.yml +0 -22
  168. package/.github/workflows/main.yml +0 -41
  169. package/.gitleaksignore +0 -19
  170. package/.prettierignore +0 -3
  171. package/.prettierrc +0 -28
  172. package/CLAUDE.md +0 -410
  173. package/copy-abi.ps1 +0 -15
  174. package/dist/tests/facade.test.js.map +0 -1
  175. package/index.ts +0 -2
  176. package/jest-config.ts +0 -9
  177. package/jest.config.js +0 -8
  178. package/rollup.config.js +0 -45
  179. package/tsconfig.json +0 -27
  180. /package/dist/{tests/facade.test.d.ts → domain/au-minimum.test.d.ts} +0 -0
@@ -0,0 +1,52 @@
1
+ import { providers } from 'ethers';
2
+
3
+ import { apyToEpochRate, epochRateToApy } from '../../domain/rates';
4
+ import { CHAIN_CONFIGS } from '../../facade/chain-configs';
5
+ import { SdkConfig } from '../../sdk-config';
6
+
7
+ import { KSULocking } from './locking';
8
+
9
+ // Offline: the constructor only builds contract instances. Nothing here calls
10
+ // the RPC or the subgraph.
11
+ function locking(): KSULocking {
12
+ const chain = CHAIN_CONFIGS.base;
13
+ const config = new SdkConfig({
14
+ subgraphUrl: 'https://example.invalid/subgraph',
15
+ contracts: chain.contracts,
16
+ UNUSED_LENDING_POOL_IDS: [''],
17
+ });
18
+ return new KSULocking(
19
+ config,
20
+ new providers.StaticJsonRpcProvider(chain.rpcUrls[0], chain.chainId),
21
+ );
22
+ }
23
+
24
+ describe('KSULocking.calculateApy', () => {
25
+ it('compounds the epoch rate instead of XOR-ing it', () => {
26
+ // The old body was `(1 + r) ^ (EPOCHS_IN_YEAR - 1)` — bitwise XOR on
27
+ // int32 operands, so every realistic rate returned the constant 50.
28
+ for (const r of [0.001, 0.0025, 0.003, 0.005]) {
29
+ expect(locking().calculateApy(r)).toBe(epochRateToApy(r));
30
+ expect(locking().calculateApy(r)).not.toBe(50);
31
+ }
32
+ });
33
+
34
+ it('lands on the APYs the platform actually quotes', () => {
35
+ // Every live tranche APY, back through its own per-epoch rate.
36
+ for (const apy of [0.1, 0.12, 0.14, 0.16, 0.22, 0.3]) {
37
+ expect(locking().calculateApy(apyToEpochRate(apy))).toBeCloseTo(
38
+ apy,
39
+ 10,
40
+ );
41
+ }
42
+ expect(locking().calculateApy(0)).toBe(0);
43
+ });
44
+
45
+ it('agrees with DataService.calculateApyForTranche', () => {
46
+ // The two used to carry separate copies of the constant AND separate
47
+ // (one of them wrong) formulas.
48
+ for (const r of [0.001, 0.003, 0.01]) {
49
+ expect(locking().calculateApy(r)).toBe(epochRateToApy(r));
50
+ }
51
+ });
52
+ });
@@ -17,6 +17,7 @@ import {
17
17
  IUserManagerAbi,
18
18
  IUserManagerAbi__factory,
19
19
  } from '../../contracts';
20
+ import { epochRateToApy } from '../../domain/rates';
20
21
  import { SdkConfig } from '../../sdk-config';
21
22
  import {
22
23
  getAllTrancheConfigurationsQuery,
@@ -265,9 +266,22 @@ export class KSULocking {
265
266
  );
266
267
  }
267
268
 
269
+ /**
270
+ * A per-epoch interest rate compounded into an APY.
271
+ *
272
+ * This used to read `(1 + epochInterestRate) ^ (EPOCHS_IN_YEAR - 1)`.
273
+ * `^` is JavaScript's BITWISE XOR, not exponentiation: both operands were
274
+ * coerced to int32, so for a realistic epoch rate of ~0.003 it computed
275
+ * `1 ^ 51` and returned the constant 50 — a 5000% APY — for every tranche,
276
+ * regardless of its rate. Its only caller,
277
+ * `calculateUserLockProjectedProtocolFeeRewards`, multiplied that by each
278
+ * tranche balance, so its projection was nonsense rather than merely
279
+ * imprecise.
280
+ *
281
+ * Now the same compounding every other rate in the SDK uses.
282
+ */
268
283
  calculateApy(epochInterestRate: number): number {
269
- const EPOCHS_IN_YEAR = 52.17857;
270
- return (1 + epochInterestRate) ^ (EPOCHS_IN_YEAR - 1);
284
+ return epochRateToApy(epochInterestRate);
271
285
  }
272
286
 
273
287
  async getUserLocks(userAddress: string): Promise<UserLock[]> {
@@ -1,12 +1,4 @@
1
- import {
2
- authentication,
3
- AuthenticationClient,
4
- createDirectus,
5
- DirectusClient,
6
- readItems,
7
- rest,
8
- RestClient,
9
- } from '@directus/sdk';
1
+ import { readItems } from '@directus/sdk';
10
2
  import { Provider } from '@ethersproject/providers';
11
3
  import {
12
4
  BigNumber,
@@ -43,7 +35,10 @@ import {
43
35
  } from '../../contracts';
44
36
  import { SdkConfig } from '../../sdk-config';
45
37
  import { DataService } from '../DataService/data-service';
46
- import { DirectusSchema } from '../DataService/directus-types';
38
+ import {
39
+ createDirectusClient,
40
+ KasuDirectusClient,
41
+ } from '../DataService/directus-client';
47
42
 
48
43
  import { mapUserRequestEventType } from './helper';
49
44
  import {
@@ -78,9 +73,7 @@ import {
78
73
  export class UserLending {
79
74
  private readonly _graph: GraphQLClient;
80
75
 
81
- private readonly _directus: DirectusClient<DirectusSchema> &
82
- AuthenticationClient<DirectusSchema> &
83
- RestClient<DirectusSchema>;
76
+ private readonly _directus: KasuDirectusClient;
84
77
  private _dataService: DataService;
85
78
  private readonly _userManagerAbi: IUserManagerAbi;
86
79
  private readonly _lendingPoolManagerAbi: ILendingPoolManagerAbi;
@@ -117,9 +110,7 @@ export class UserLending {
117
110
  signerOrProvider,
118
111
  );
119
112
  this._dataService = new DataService(_kasuConfig, signerOrProvider);
120
- this._directus = createDirectus<DirectusSchema>(_kasuConfig.directusUrl)
121
- .with(authentication())
122
- .with(rest());
113
+ this._directus = createDirectusClient(_kasuConfig.directusUrl);
123
114
  }
124
115
 
125
116
  async getUserTotalPendingAndActiveDepositedAmount(
@@ -372,11 +363,16 @@ export class UserLending {
372
363
  unusedPools: this._kasuConfig.UNUSED_LENDING_POOL_IDS,
373
364
  epochId,
374
365
  }),
375
- this._directus.request(
376
- readItems('PoolOverview', {
377
- fields: ['id', 'poolName', 'subheading'],
378
- }),
379
- ),
366
+ // Directus supplies the display pool NAME only; without it the
367
+ // raw subgraph name is used, which is what the fallback below
368
+ // already does for a pool with no CMS entry.
369
+ this._kasuConfig.directusUrl
370
+ ? this._directus.request(
371
+ readItems('PoolOverview', {
372
+ fields: ['id', 'poolName', 'subheading'],
373
+ }),
374
+ )
375
+ : [],
380
376
  ]);
381
377
 
382
378
  const retn: UserRequest[] = [];
@@ -1,42 +1,63 @@
1
+ /**
2
+ * Live-network spec. It talks to a real subgraph and a real RPC, so it is
3
+ * OPT-IN: it runs only under `LIVE_TESTS=1` (`npm run test:live`) and is
4
+ * skipped by `npm test` and `npm run test:unit`. A network problem must never
5
+ * be able to fail a pull request that did not touch the network.
6
+ *
7
+ * Known state: the stack it points at (`kasu-wip-sepolia` on The Graph Studio,
8
+ * with Base Sepolia addresses) is decommissioned, so `npm run test:live` fails
9
+ * on a missing deployment. That is pre-existing and unrelated to the gate; the
10
+ * spec needs retargeting at a live deployment before it means anything.
11
+ */
1
12
  import * as ethers from 'ethers';
2
13
 
3
14
  import { KasuSdk } from '..';
4
15
  import { SdkConfig } from '../sdk-config';
5
16
 
6
- test('subgraphCall', async () => {
7
- const provider = new ethers.providers.JsonRpcProvider(
8
- 'https://sepolia.base.org',
9
- );
17
+ const live = process.env.LIVE_TESTS === '1';
10
18
 
11
- const wallet = new ethers.Wallet(
12
- 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd',
13
- provider,
14
- );
15
- const config = new SdkConfig({
16
- subgraphUrl:
17
- 'https://api.studio.thegraph.com/query/63245/kasu-wip-sepolia/version/latest',
18
- contracts: {
19
- IKSULocking: '0x529A81c11ab6176c5E88670d293BB771800066a2',
20
- IKSULockBonus: '0xBBfFd5F744156FFc526df12F5e09dC7b208Be740',
21
- KSUToken: '0xa0f698Feb9Bc2BeA6E85eb071D5E3F59dc5bC56b',
22
- UserManager: '0xA788e9223fDd7c9Db91Ef133BbeB73515c174773',
23
- LendingPoolManager: '0xc074Aaf2565aae18db2c7498ee1387610a809F40',
24
- KasuAllowList: '0xaE94F9D187c9eA649ADd4966340831F7cc62B69c',
25
- SystemVariables: '0xB174a3240B23e595e90bC2736A5b8ec674Cba73A',
26
- UserLoyaltyRewards: '0x259631CE76FD9F65296549Cd81232aa59D53Dd0c',
27
- KsuPrice: '0x2027192aCFB4810Ad734A212F19d7030F698aCE3',
28
- ClearingCoordinator: '0x2027192aCFB4810Ad734A212F19d7030F698aCE3',
29
- KasuNFTs: '0x0000000000000000000000000000000000000000',
30
- ExternalTVL: '0x0000000000000000000000000000000000000000',
31
- },
32
- directusUrl: 'https://kasu-finance.directus.app',
33
- UNUSED_LENDING_POOL_IDS: [''],
34
- });
35
- const sdk = new KasuSdk(config, wallet);
19
+ (live ? describe : describe.skip)('live network — subgraph read', () => {
20
+ it('reads a user APY bonus through the subgraph', async () => {
21
+ const provider = new ethers.providers.JsonRpcProvider(
22
+ 'https://sepolia.base.org',
23
+ );
24
+
25
+ // Generated per run. This spec only reads, so the wallet never needs
26
+ // funds or a key that outlives the process — and a public repository
27
+ // must never carry one.
28
+ const wallet = ethers.Wallet.createRandom().connect(provider);
29
+
30
+ const config = new SdkConfig({
31
+ subgraphUrl:
32
+ 'https://api.studio.thegraph.com/query/63245/kasu-wip-sepolia/version/latest',
33
+ contracts: {
34
+ IKSULocking: '0x529A81c11ab6176c5E88670d293BB771800066a2',
35
+ IKSULockBonus: '0xBBfFd5F744156FFc526df12F5e09dC7b208Be740',
36
+ // The allow below is for a public Base Sepolia contract
37
+ // address, not a secret: the generic-api-key rule fires on a
38
+ // "Token" key name sitting next to a long hex literal.
39
+ KSUToken: '0xa0f698Feb9Bc2BeA6E85eb071D5E3F59dc5bC56b', // gitleaks:allow
40
+ UserManager: '0xA788e9223fDd7c9Db91Ef133BbeB73515c174773',
41
+ LendingPoolManager: '0xc074Aaf2565aae18db2c7498ee1387610a809F40',
42
+ KasuAllowList: '0xaE94F9D187c9eA649ADd4966340831F7cc62B69c',
43
+ SystemVariables: '0xB174a3240B23e595e90bC2736A5b8ec674Cba73A',
44
+ UserLoyaltyRewards:
45
+ '0x259631CE76FD9F65296549Cd81232aa59D53Dd0c',
46
+ KsuPrice: '0x2027192aCFB4810Ad734A212F19d7030F698aCE3',
47
+ ClearingCoordinator:
48
+ '0x2027192aCFB4810Ad734A212F19d7030F698aCE3',
49
+ KasuNFTs: '0x0000000000000000000000000000000000000000',
50
+ ExternalTVL: '0x0000000000000000000000000000000000000000',
51
+ },
52
+ directusUrl: 'https://kasu-finance.directus.app',
53
+ UNUSED_LENDING_POOL_IDS: [''],
54
+ });
55
+ const sdk = new KasuSdk(config, wallet);
36
56
 
37
- console.log(
38
- await sdk.UserLending.getUserApyBonus(
57
+ const bonus = await sdk.UserLending.getUserApyBonus(
39
58
  '0xef38c432682ab49095e00442aaa354e955ac03a5',
40
- ),
41
- );
59
+ );
60
+
61
+ expect(bonus).toBeDefined();
62
+ });
42
63
  });
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- /**/*.js
2
- src/contracts/**
3
- jest-config.ts
package/.eslintrc.json DELETED
@@ -1,90 +0,0 @@
1
- {
2
- "extends": [
3
- "plugin:@typescript-eslint/strict-type-checked",
4
- "plugin:@typescript-eslint/stylistic-type-checked",
5
- "plugin:import/errors",
6
- "plugin:import/warnings",
7
- "plugin:import/typescript",
8
- "prettier"
9
- ],
10
- "settings": {
11
- "import/resolver": {
12
- "node": {
13
- "extensions": [".js", ".jsx", ".ts", ".tsx", ".d.ts"], // add .d.ts here
14
- "moduleDirectory": ["src", "node_modules"]
15
- }
16
- }
17
- },
18
- "parserOptions": {
19
- "project": ["./tsconfig.json"] // Specify it only for TypeScript files
20
- },
21
- "ignorePatterns": [
22
- "node_modules",
23
- "src/contracts",
24
- "index.ts",
25
- "dist/**/*"
26
- ],
27
- "rules": {
28
- "@typescript-eslint/no-non-null-assertion": "warn",
29
- "@typescript-eslint/prefer-ts-expect-error": "warn",
30
- "@typescript-eslint/restrict-plus-operands": "warn",
31
- "@typescript-eslint/ban-ts-comment": [
32
- "warn",
33
- {
34
- "ts-expect-error": "allow-with-description",
35
- "ts-ignore": "allow-with-description"
36
- }
37
- ],
38
- "@typescript-eslint/ban-tslint-comment": "warn",
39
- "@typescript-eslint/no-explicit-any": "warn",
40
- "testing-library/prefer-screen-queries": "off",
41
- "@typescript-eslint/no-unused-vars": [
42
- "warn",
43
- {
44
- "argsIgnorePattern": "^_",
45
- "varsIgnorePattern": "^_"
46
- }
47
- ],
48
- "sort-imports": [
49
- "warn",
50
- {
51
- "ignoreCase": true,
52
- "ignoreDeclarationSort": true
53
- }
54
- ],
55
- "import/order": [
56
- "error",
57
- {
58
- "groups": [
59
- "builtin",
60
- "external",
61
- "internal",
62
- "parent",
63
- "sibling",
64
- "index"
65
- ],
66
- "pathGroups": [
67
- {
68
- "pattern": "src/**",
69
- "group": "internal",
70
- "position": "before"
71
- },
72
- {
73
- "pattern": "test/**",
74
- "group": "internal",
75
- "position": "before"
76
- }
77
- ],
78
- "pathGroupsExcludedImportTypes": ["builtin", "external"],
79
- "newlines-between": "always",
80
- "alphabetize": {
81
- "order": "asc",
82
- "caseInsensitive": true
83
- }
84
- }
85
- ],
86
- "@typescript-eslint/explicit-function-return-type": "error",
87
- "@typescript-eslint/explicit-module-boundary-types": "error"
88
- },
89
- "plugins": ["@typescript-eslint", "import"]
90
- }
@@ -1,39 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- - develop
8
- pull_request:
9
- branches:
10
- - main
11
- - develop
12
-
13
- permissions:
14
- contents: read
15
-
16
- jobs:
17
- quality-checks:
18
- runs-on: ubuntu-latest
19
- steps:
20
- - name: Checkout repository
21
- uses: actions/checkout@v4
22
-
23
- - name: Set up Node.js
24
- uses: actions/setup-node@v4
25
- with:
26
- node-version: 20
27
- cache: npm
28
-
29
- - name: Install dependencies
30
- run: npm ci
31
-
32
- - name: Generate contract typings
33
- run: npm run build-tc
34
-
35
- - name: Lint & type-check
36
- run: npm run build
37
-
38
- - name: Bundle library
39
- run: npm run rollup-build
@@ -1,22 +0,0 @@
1
- name: gitleaks
2
-
3
- on:
4
- push:
5
- branches: [main, master, develop]
6
- pull_request:
7
-
8
- permissions:
9
- contents: read
10
-
11
- jobs:
12
- gitleaks:
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v4
16
- with:
17
- fetch-depth: 0
18
-
19
- - name: Run gitleaks
20
- run: |
21
- curl -sSfL https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz | tar -xz gitleaks
22
- ./gitleaks git --redact --no-banner .
@@ -1,41 +0,0 @@
1
- name: Verify release tag
2
-
3
- # npm publishes are intentionally manual (policy: always run `npm publish`
4
- # locally as a kasu_finance org member). This workflow only verifies the
5
- # pushed tag matches package.json — it does NOT publish.
6
-
7
- on:
8
- push:
9
- tags:
10
- - 'v[0-9]+.[0-9]+.[0-9]+'
11
-
12
- workflow_dispatch:
13
-
14
- jobs:
15
- verify:
16
- runs-on: ubuntu-latest
17
- permissions:
18
- contents: read
19
-
20
- steps:
21
- - uses: actions/checkout@v4
22
-
23
- - name: Get tag version
24
- id: tag_version
25
- run: |
26
- RAW_TAG="${GITHUB_REF#refs/tags/}"
27
- echo "TAG_VERSION=${RAW_TAG#v}" >> "$GITHUB_OUTPUT"
28
-
29
- - name: Read package version
30
- id: package_version
31
- run: |
32
- PKG_VERSION=$(node -p "require('./package.json').version")
33
- echo "PACKAGE_VERSION=$PKG_VERSION" >> "$GITHUB_OUTPUT"
34
-
35
- - name: Ensure tag matches package.json
36
- run: |
37
- if [ "${{ steps.tag_version.outputs.TAG_VERSION }}" != "${{ steps.package_version.outputs.PACKAGE_VERSION }}" ]; then
38
- echo "Tag ${{ steps.tag_version.outputs.TAG_VERSION }} does not match package.json ${{ steps.package_version.outputs.PACKAGE_VERSION }}."
39
- exit 1
40
- fi
41
- echo "Tag ${{ steps.tag_version.outputs.TAG_VERSION }} matches package.json. Run 'npm publish' locally to release."
package/.gitleaksignore DELETED
@@ -1,19 +0,0 @@
1
- # Baseline: historical findings triaged 2026-08-11 (real ones rotated, rest false positives).
2
- # New findings will still fail CI. Format: commit:file:rule:line
3
- 0a13e5c82c4b0dea51a1bca2bcffd4dbe7d9e9c8:src/config/sdk/mainnet.config.ts:generic-api-key:9
4
- 0a13e5c82c4b0dea51a1bca2bcffd4dbe7d9e9c8:src/config/sdk/testnet.config.ts:generic-api-key:9
5
- 1a0e64886602fdbb0789b72e3be80460dfb2a9bc:src/tests/sample.test.ts:generic-api-key:18
6
- 41992e186efdd602e49a07a9cfaa17a046194afd:src/tests/sample.test.ts:generic-api-key:20
7
- 61345a2c016dd28bd3fe647b01ae92321f4e6797:src/config/sdk/mainnet.config.ts:generic-api-key:9
8
- 61345a2c016dd28bd3fe647b01ae92321f4e6797:src/config/sdk/testnet.config.ts:generic-api-key:9
9
- 678e94f28e9894246569775e06b7bfc145c90db9:src/config/sdk/mainnet.config.ts:generic-api-key:9
10
- 678e94f28e9894246569775e06b7bfc145c90db9:src/config/sdk/testnet.config.ts:generic-api-key:9
11
- 76241c92f25050ca6b73e77ce0514abc8c5038d8:src/config/sdk/mainnet.config.ts:generic-api-key:9
12
- 76241c92f25050ca6b73e77ce0514abc8c5038d8:src/config/sdk/testnet.config.ts:generic-api-key:9
13
- aa4522559522cf1f207b834fbd0318ef96f1f635:src/app/api/kyc-challenge/route.ts:generic-api-key:5
14
- c65a422c4f96ba302c047fe1a4e3d6d74dcc2744:src/facade/chain-configs.ts:generic-api-key:18
15
- cee7050d62ae95f1b6d88592de8eaff576719d28:src/tests/sample.test.ts:generic-api-key:18
16
- f085d18b3b818f5853a934aee12ce1611afc738e:src/config/sdk/mainnet.config.ts:generic-api-key:9
17
- f085d18b3b818f5853a934aee12ce1611afc738e:src/config/sdk/testnet.config.ts:generic-api-key:9
18
- f92e12c74df7990a519eec7c4940a655cbaa3160:src/actions/getTokenPrice.ts:generic-api-key:52
19
- fc75e2491f414032d69a352f7a0e1fcd3f515f99:.env.local:generic-api-key:2
package/.prettierignore DELETED
@@ -1,3 +0,0 @@
1
- .nyc_output
2
- package-lock.json
3
- src/contracts/**
package/.prettierrc DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "arrowParens": "always",
3
- "singleQuote": true,
4
- "tabWidth": 4,
5
- "semi": true,
6
- "trailingComma": "all",
7
- "endOfLine": "auto",
8
- "overrides": [
9
- {
10
- "files": ".prettierrc",
11
- "options": {
12
- "parser": "json"
13
- }
14
- },
15
- {
16
- "files": ["*.ts", "*.mts"],
17
- "options": {
18
- "parser": "typescript"
19
- }
20
- },
21
- {
22
- "files": ["*.yml", "*.yaml"],
23
- "options": {
24
- "tabWidth": 2
25
- }
26
- }
27
- ]
28
- }