@naviprotocol/lending 1.0.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.
@@ -0,0 +1,428 @@
1
+ import { SuiClient } from '@mysten/sui/client';
2
+ import { TransactionResult as TransactionResultType } from '@mysten/sui/transactions';
3
+
4
+ /**
5
+ * Union type for transaction results from Sui blockchain
6
+ *
7
+ * This type represents various forms of transaction results including
8
+ * direct results, nested results, and standard transaction result types.
9
+ */
10
+ export type TransactionResult = {
11
+ $kind: 'Result';
12
+ Result: number;
13
+ } | {
14
+ $kind: 'NestedResult';
15
+ NestedResult: [number, number];
16
+ } | TransactionResultType;
17
+ export type AccountCap = string;
18
+ /**
19
+ * Environment configuration options
20
+ */
21
+ export type EnvOption = {
22
+ /** Environment setting: 'dev' for development, 'prod' for production */
23
+ env: 'dev' | 'prod';
24
+ };
25
+ /**
26
+ * Account capability options for lending operations
27
+ */
28
+ export type AccountCapOption = {
29
+ /** Account capability object ID or transaction result */
30
+ accountCap: string | TransactionResult;
31
+ };
32
+ /**
33
+ * Sui client configuration options
34
+ */
35
+ export type SuiClientOption = {
36
+ /** Sui client instance */
37
+ client: SuiClient;
38
+ };
39
+ /**
40
+ * Caching configuration options
41
+ */
42
+ export type CacheOption = {
43
+ /** Whether to disable caching for this operation */
44
+ disableCache?: boolean;
45
+ /** Cache expiration time in milliseconds */
46
+ cacheTime?: number;
47
+ };
48
+ /**
49
+ * User lending information for a specific asset
50
+ */
51
+ export type UserLendingInfo = {
52
+ /** Asset identifier */
53
+ assetId: number;
54
+ /** Current borrow balance */
55
+ borrowBalance: string;
56
+ /** Current supply balance */
57
+ supplyBalance: string;
58
+ /** Pool information */
59
+ pool: Pool;
60
+ };
61
+ /**
62
+ * Lending reward information for a user
63
+ */
64
+ export type LendingReward = {
65
+ /** Amount of reward available to claim */
66
+ userClaimableReward: number;
67
+ /** Amount of reward already claimed */
68
+ userClaimedReward?: string;
69
+ /** Reward option identifier */
70
+ option: number;
71
+ /** Array of rule IDs for this reward */
72
+ ruleIds: string[];
73
+ /** Asset coin type */
74
+ assetCoinType: string;
75
+ /** Reward coin type */
76
+ rewardCoinType: string;
77
+ /** Asset identifier */
78
+ assetId: number;
79
+ };
80
+ /**
81
+ * Summary of lending rewards for an asset
82
+ */
83
+ export type LendingRewardSummary = {
84
+ /** Asset identifier */
85
+ assetId: number;
86
+ /** Type of reward */
87
+ rewardType: number;
88
+ /** Available rewards by coin type */
89
+ rewards: {
90
+ coinType: string;
91
+ available: string;
92
+ }[];
93
+ };
94
+ /**
95
+ * Historical record of claimed rewards
96
+ */
97
+ export type HistoryClaimedReward = {
98
+ /** Amount claimed */
99
+ amount: string;
100
+ /** Coin type of the reward */
101
+ coinType: string;
102
+ /** Pool identifier */
103
+ pool: string;
104
+ /** User address who claimed */
105
+ sender: string;
106
+ /** Timestamp of claim */
107
+ timestamp: string;
108
+ /** Token price at time of claim */
109
+ tokenPrice: number;
110
+ };
111
+ /**
112
+ * Lending claimed reward with transaction details
113
+ */
114
+ export type LendingClaimedReward = {
115
+ /** Coin transaction result */
116
+ coin: TransactionResult;
117
+ /** Pool identifier */
118
+ identifier: Pool;
119
+ };
120
+ /**
121
+ * Transaction information for lending operations
122
+ */
123
+ export type Transaction = {
124
+ /** Transaction type */
125
+ type: string;
126
+ /** Transaction status */
127
+ status: string;
128
+ /** Changes in coin balances */
129
+ coinChanges: {
130
+ /** Coin symbol */
131
+ symbol: string;
132
+ /** Amount changed */
133
+ amount: string;
134
+ }[];
135
+ /** Transaction timestamp */
136
+ timestamp: string;
137
+ /** Transaction digest */
138
+ digest: string;
139
+ };
140
+ /**
141
+ * Comprehensive pool information for lending operations
142
+ */
143
+ export type Pool = {
144
+ /** Maximum borrow capacity */
145
+ borrowCapCeiling: string;
146
+ /** Coin type for this pool */
147
+ coinType: string;
148
+ /** Sui coin type */
149
+ suiCoinType: string;
150
+ /** Current borrow index */
151
+ currentBorrowIndex: string;
152
+ /** Current borrow rate */
153
+ currentBorrowRate: string;
154
+ /** Current supply index */
155
+ currentSupplyIndex: string;
156
+ /** Current supply rate */
157
+ currentSupplyRate: string;
158
+ /** Pool identifier */
159
+ id: number;
160
+ /** Whether this is an isolated pool */
161
+ isIsolated: boolean;
162
+ /** Last update timestamp */
163
+ lastUpdateTimestamp: string;
164
+ /** Loan-to-value ratio */
165
+ ltv: string;
166
+ /** Oracle identifier */
167
+ oracleId: number;
168
+ /** Maximum supply capacity */
169
+ supplyCapCeiling: string;
170
+ /** Treasury balance */
171
+ treasuryBalance: string;
172
+ /** Treasury factor */
173
+ treasuryFactor: string;
174
+ /** Total supply amount */
175
+ totalSupplyAmount: string;
176
+ /** Minimum transaction amount */
177
+ minimumAmount: string;
178
+ /** Remaining supply capacity */
179
+ leftSupply: string;
180
+ /** Valid borrow amount */
181
+ validBorrowAmount: string;
182
+ /** Currently borrowed amount */
183
+ borrowedAmount: string;
184
+ /** Remaining borrow capacity */
185
+ leftBorrowAmount: string;
186
+ /** Available borrow amount */
187
+ availableBorrow: string;
188
+ /** Oracle price information */
189
+ oracle: {
190
+ /** Price decimal places */
191
+ decimal: 8;
192
+ /** Oracle value */
193
+ value: string;
194
+ /** Current price */
195
+ price: string;
196
+ /** Oracle identifier */
197
+ oracleId: number;
198
+ /** Whether oracle is valid */
199
+ valid: boolean;
200
+ };
201
+ /** Total supply */
202
+ totalSupply: string;
203
+ /** Total borrow */
204
+ totalBorrow: string;
205
+ /** Borrow rate calculation factors */
206
+ borrowRateFactors: {
207
+ fields: {
208
+ /** Base interest rate */
209
+ baseRate: string;
210
+ /** Rate multiplier */
211
+ multiplier: string;
212
+ /** Jump rate multiplier */
213
+ jumpRateMultiplier: string;
214
+ /** Optimal utilization rate */
215
+ optimalUtilization: string;
216
+ /** Reserve factor */
217
+ reserveFactor: string;
218
+ };
219
+ };
220
+ /** Liquidation parameters */
221
+ liquidationFactor: {
222
+ /** Liquidation bonus */
223
+ bonus: string;
224
+ /** Liquidation ratio */
225
+ ratio: string;
226
+ /** Liquidation threshold */
227
+ threshold: string;
228
+ };
229
+ /** Supply incentive APY information */
230
+ supplyIncentiveApyInfo: {
231
+ /** Vault APR */
232
+ vaultApr: string;
233
+ /** Boosted APR */
234
+ boostedApr: string;
235
+ /** Reward coin types */
236
+ rewardCoin: string[];
237
+ /** Total APY */
238
+ apy: string;
239
+ /** Volo APY */
240
+ voloApy: string;
241
+ /** Staking yield APY */
242
+ stakingYieldApy: string;
243
+ /** Treasury APY */
244
+ treasuryApy: string;
245
+ };
246
+ /** Borrow incentive APY information */
247
+ borrowIncentiveApyInfo: {
248
+ /** Vault APR */
249
+ vaultApr: string;
250
+ /** Boosted APR */
251
+ boostedApr: string;
252
+ /** Reward coin types */
253
+ rewardCoin: string[];
254
+ /** Total APY */
255
+ apy: string;
256
+ /** Volo APY */
257
+ voloApy: string;
258
+ /** Staking yield APY */
259
+ stakingYieldApy: string;
260
+ /** Treasury APY */
261
+ treasuryApy: string;
262
+ };
263
+ /** Token information */
264
+ token: {
265
+ /** Coin type */
266
+ coinType: string;
267
+ /** Token decimals */
268
+ decimals: number;
269
+ /** Token logo URI */
270
+ logoURI: string;
271
+ /** Token symbol */
272
+ symbol: string;
273
+ };
274
+ /** Contract addresses */
275
+ contract: {
276
+ /** Reserve ID */
277
+ reserveId: string;
278
+ /** Pool address */
279
+ pool: string;
280
+ /** Optional reward fund ID */
281
+ rewardFundId?: string;
282
+ };
283
+ };
284
+ /**
285
+ * Asset identifier - can be string, Pool object, or number
286
+ */
287
+ export type AssetIdentifier = string | Pool | number;
288
+ /**
289
+ * Flash loan asset configuration
290
+ */
291
+ export type FloashloanAsset = {
292
+ /** Maximum flash loan amount */
293
+ max: string;
294
+ /** Minimum flash loan amount */
295
+ min: string;
296
+ /** Asset identifier */
297
+ assetId: number;
298
+ /** Pool identifier */
299
+ poolId: string;
300
+ /** Supplier fee percentage */
301
+ supplierFee: number;
302
+ /** Flash loan fee percentage */
303
+ flashloanFee: number;
304
+ /** Coin type */
305
+ coinType: string;
306
+ };
307
+ /**
308
+ * Pool statistics and metrics
309
+ */
310
+ export type PoolStats = {
311
+ /** Total value locked */
312
+ tvl: number;
313
+ /** Total borrow in USD */
314
+ totalBorrowUsd: number;
315
+ /** Average utilization rate */
316
+ averageUtilization: number;
317
+ /** Maximum APY */
318
+ maxApy: number;
319
+ /** Number of users */
320
+ userAmount: number;
321
+ /** Number of active users */
322
+ interactionUserAmount: number;
323
+ /** Borrow fee percentage */
324
+ borrowFee: number;
325
+ /** Borrow fee collection address */
326
+ borrowFeeAddress: string;
327
+ };
328
+ /**
329
+ * Oracle price feed configuration
330
+ */
331
+ export type OraclePriceFeed = {
332
+ /** Oracle identifier */
333
+ oracleId: number;
334
+ /** Feed identifier */
335
+ feedId: string;
336
+ /** Asset identifier */
337
+ assetId: number;
338
+ /** Pyth price feed ID */
339
+ pythPriceFeedId: string;
340
+ /** Pyth price info object */
341
+ pythPriceInfoObject: string;
342
+ /** Coin type */
343
+ coinType: string;
344
+ /** Price decimal places */
345
+ priceDecimal: number;
346
+ /** Supra pair identifier */
347
+ supraPairId: number;
348
+ };
349
+ /**
350
+ * Lending protocol configuration
351
+ */
352
+ export type LendingConfig = {
353
+ /** Main package address */
354
+ package: string;
355
+ /** Storage contract address */
356
+ storage: string;
357
+ /** Incentive V2 contract address */
358
+ incentiveV2: string;
359
+ /** Incentive V3 contract address */
360
+ incentiveV3: string;
361
+ /** Price oracle contract address */
362
+ priceOracle: string;
363
+ /** UI getter contract address */
364
+ uiGetter: string;
365
+ /** Reserve parent ID */
366
+ reserveParentId: string;
367
+ /** Flash loan configuration address */
368
+ flashloanConfig: string;
369
+ /** Flash loan supported assets address */
370
+ flashloanSupportedAssets: string;
371
+ /** Oracle configuration */
372
+ oracle: {
373
+ /** Package ID */
374
+ packageId: string;
375
+ /** Price oracle contract address */
376
+ priceOracle: string;
377
+ /** Oracle admin capability ID */
378
+ oracleAdminCap: string;
379
+ /** Oracle configuration object */
380
+ oracleConfig: string;
381
+ /** Pyth state ID */
382
+ pythStateId: string;
383
+ /** Wormhole state ID */
384
+ wormholeStateId: string;
385
+ /** Supra oracle holder address */
386
+ supraOracleHolder: string;
387
+ /** Sender address for oracle updates */
388
+ sender: string;
389
+ /** Gas object ID for oracle updates */
390
+ gasObject: string;
391
+ /** Price feeds */
392
+ feeds: OraclePriceFeed[];
393
+ };
394
+ };
395
+ /**
396
+ * Fee detail information for lending operations
397
+ */
398
+ export type FeeDetail = {
399
+ /** Coin identifier */
400
+ coinId: string;
401
+ /** Coin symbol */
402
+ coinSymbol: string;
403
+ /** Coin type */
404
+ coinType: string;
405
+ /** Fee object identifier */
406
+ feeObjectId: string;
407
+ /** Current fee amount */
408
+ currentAmount: number;
409
+ /** Current price */
410
+ price: number;
411
+ /** Current value in USD */
412
+ currentValue: number;
413
+ };
414
+ /**
415
+ * Union type for coin objects in transactions
416
+ *
417
+ * This type represents various ways to reference coins in transaction building,
418
+ * including transaction results, gas coins, input references, and direct strings.
419
+ */
420
+ export type CoinObject = TransactionResult | {
421
+ $kind: 'GasCoin';
422
+ GasCoin: true;
423
+ } | {
424
+ $kind: 'Input';
425
+ Input: number;
426
+ type?: 'object';
427
+ } | string;
428
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAE1F;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GACzB;IACE,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf,GACD;IACE,KAAK,EAAE,cAAc,CAAA;IACrB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B,GACD,qBAAqB,CAAA;AAEzB,MAAM,M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ACvC,SAAS,EAAE,MAAM,CAAA;QACjB,kBAAkB;QAClB,KAAK,EAAE,eAAe,EAAE,CAAA;KACzB,CAAA;CACF,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,yBAAyB;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,2BAA2B;IAC3B,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,iBAAiB,GACjB;IACE,KAAK,EAAE,SAAS,CAAA;IAChB,OAAO,EAAE,IAAI,CAAA;CACd,GACD;IACE,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,GACD,MAAM,CAAA"}
@@ -0,0 +1,113 @@
1
+ import { Pool, TransactionResult } from './types';
2
+ import { DevInspectResults, SuiClient } from '@mysten/sui/client';
3
+ import { Transaction } from '@mysten/sui/transactions';
4
+ import { BcsType } from '@mysten/sui/bcs';
5
+ import { SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
6
+
7
+ /**
8
+ * Default Sui client instance configured for mainnet
9
+ */
10
+ export declare const suiClient: SuiClient;
11
+ /**
12
+ * Wraps a function with singleton behavior to prevent duplicate concurrent calls
13
+ *
14
+ * This decorator ensures that if the same function is called with the same arguments
15
+ * while a previous call is still pending, it returns the existing promise instead
16
+ * of making a new call.
17
+ *
18
+ * @param fn - Function to wrap with singleton behavior
19
+ * @returns Wrapped function with singleton behavior
20
+ */
21
+ export declare function withSingleton<T extends (...args: any[]) => Promise<any>>(fn: T): T;
22
+ /**
23
+ * Wraps a function with caching behavior
24
+ *
25
+ * This decorator caches function results based on arguments and cache options.
26
+ * It respects cache time settings and can be disabled per call.
27
+ *
28
+ * @param fn - Function to wrap with caching behavior
29
+ * @returns Wrapped function with caching behavior
30
+ */
31
+ export declare function withCache<T extends (...args: any[]) => Promise<any>>(fn: T): T;
32
+ /**
33
+ * Converts object keys from snake_case to camelCase recursively
34
+ *
35
+ * This function transforms all keys in an object (including nested objects and arrays)
36
+ * from snake_case format to camelCase format.
37
+ *
38
+ * @param obj - Object to transform
39
+ * @returns Object with camelCase keys
40
+ */
41
+ export declare function camelize<T extends Record<string, any>>(obj: T): T;
42
+ /**
43
+ * Parses a value for use in transaction building
44
+ *
45
+ * This function converts various value types into the appropriate format
46
+ * for transaction building, handling both primitive types and existing
47
+ * transaction results.
48
+ *
49
+ * @param value - Value to parse (string, number, boolean, or object)
50
+ * @param format - Format function to apply to the value
51
+ * @returns Transaction result in the appropriate format
52
+ */
53
+ export declare function parseTxValue(value: string | number | boolean | object, format: any): TransactionResult;
54
+ /**
55
+ * Parses a pool value for use in transaction building
56
+ *
57
+ * This function handles different pool representations and converts them
58
+ * to the appropriate transaction object format.
59
+ *
60
+ * @param tx - Transaction object to build
61
+ * @param value - Pool value (string, Pool object, or TransactionResult)
62
+ * @returns Transaction result representing the pool
63
+ */
64
+ export declare function parseTxPoolValue(tx: Transaction, value: string | Pool | TransactionResult): {
65
+ $kind: "Result";
66
+ Result: number;
67
+ } | {
68
+ $kind: "NestedResult";
69
+ NestedResult: [number, number];
70
+ } | {
71
+ $kind: "Input";
72
+ Input: number;
73
+ type?: "object";
74
+ };
75
+ /**
76
+ * Parses the result of a devInspectTransactionBlock call
77
+ *
78
+ * This function extracts and parses return values from transaction inspection
79
+ * results using BCS (Binary Canonical Serialization) types.
80
+ *
81
+ * @param data - DevInspectResults from transaction inspection
82
+ * @param parseTypes - Array of BCS types to parse the return values
83
+ * @param options - Optional configuration including error handling
84
+ * @returns Parsed result data
85
+ */
86
+ export declare function parseDevInspectResult<T>(data: DevInspectResults, parseTypes: BcsType<any>[], options?: {
87
+ throwError?: boolean;
88
+ }): T;
89
+ /**
90
+ * Normalizes a coin type string using Sui's struct tag normalization
91
+ *
92
+ * @param coinType - Coin type string to normalize
93
+ * @returns Normalized coin type string
94
+ */
95
+ export declare function normalizeCoinType(coinType: string): string;
96
+ /**
97
+ * Processes health factor values from contract format to human-readable format
98
+ *
99
+ * This function converts the raw health factor value from the contract
100
+ * (which is typically a large integer) to a more readable decimal format.
101
+ *
102
+ * @param hf - Raw health factor value from contract
103
+ * @returns Processed health factor value
104
+ */
105
+ export declare function processContractHealthFactor(hf: number): number;
106
+ /**
107
+ * Pyth price service connection for oracle price feeds
108
+ *
109
+ * This connection is used to fetch real-time price data from the Pyth network
110
+ * for various assets in the lending protocol.
111
+ */
112
+ export declare const suiPythConnection: SuiPriceServiceConnection;
113
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAgC,IAAI,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AACpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAA;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAEpE;;GAEG;AACH,eAAO,MAAM,SAAS,WAEpB,CAAA;AAyBF;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAYlF;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAiC9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAajE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EACzC,MAAM,EAAE,GAAG,GACV,iBAAiB,CAKnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,iBAAiB;;;;;;;;;;EAQzF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,IAAI,EAAE,iBAAiB,EACvB,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,EAC1B,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,GACA,CAAC,CAgBH;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,UAEjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,MAAM,UAMrD;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,2BAE5B,CAAA"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@naviprotocol/lending",
3
+ "version": "1.0.0",
4
+ "description": "NAVI Lending SDK",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "navi",
8
+ "lending",
9
+ "sui"
10
+ ],
11
+ "author": "NAVI",
12
+ "homepage": "https://navprotocol.io",
13
+ "bugs": "https://github.com/naviprotocol/naviprotocol-monorepo/issues",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/naviprotocol/naviprotocol-monorepo.git"
17
+ },
18
+ "main": "dist/index.cjs.js",
19
+ "module": "dist/index.esm.js",
20
+ "types": "dist/index.d.ts",
21
+ "source": "src/index.ts",
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "exports": {
27
+ "./package.json": "./package.json",
28
+ ".": {
29
+ "import": {
30
+ "types": "./dist/index.d.ts",
31
+ "node": "./dist/index.cjs.js",
32
+ "default": "./dist/index.esm.js"
33
+ },
34
+ "require": "./dist/index.cjs.js"
35
+ }
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "scripts": {
41
+ "build": "run-p build:lib",
42
+ "build:lib": "vite build",
43
+ "prettier": "prettier --check src/",
44
+ "prettier:fix": "prettier --write src/",
45
+ "lint": "eslint . --ext .ts,.tsx",
46
+ "lint:fix": "eslint . --ext .ts,.tsx --fix",
47
+ "verify": "run-p prettier lint",
48
+ "verify:fix": "run-p prettier:fix lint:fix",
49
+ "test": "vitest --config ./vite.config.unit.js",
50
+ "test:watch": "vitest",
51
+ "test:coverage": "vitest run --coverage"
52
+ },
53
+ "dependencies": {
54
+ "@mysten/bcs": "^1.6.3",
55
+ "@mysten/sui": "1.34.0",
56
+ "@pythnetwork/pyth-sui-js": "^2.0.0",
57
+ "lodash.camelcase": "^4.3.0"
58
+ },
59
+ "devDependencies": {
60
+ "@types/lodash.camelcase": "^4.3.9",
61
+ "@types/node": "^20.19.1",
62
+ "tsconfig-paths": "^4.2.0",
63
+ "tslint": "^6.1.3",
64
+ "typescript": "5.8.3",
65
+ "vitest": "^3.2.2"
66
+ }
67
+ }