{"_id":"@0xmonaco/utils","_rev":"9-79fd4d7e026ddb98aa3e7aedf536aec7","name":"@0xmonaco/utils","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.0":{"name":"@0xmonaco/utils","version":"0.1.0","_id":"@0xmonaco/utils@0.1.0","maintainers":[{"name":"carsonfalcon","email":"carson@seinetwork.io"},{"name":"besated","email":"bryan@seinetwork.io"}],"dist":{"shasum":"46fbe0d6805546cf01bb403997a2d373815416f9","tarball":"https://registry.npmjs.org/@0xmonaco/utils/-/utils-0.1.0.tgz","fileCount":18,"integrity":"sha512-keXThUy+C9uRUnqza0jzto86tHA+ojx50lJXTWLFuioG22zp5m4pUHe8pi6g7QyL2dyMN3hHd/iBpG4yyBAGxg==","signatures":[{"sig":"MEQCIAzXvYEzjHUjoyV7E7TEWFNWZYKfumwGYLEGuBqtkLSCAiAwYadvrRtU5JmYV84J8bcCbKGVYG44y65mX3X5rJJV4g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8486},"main":"./dist/index.js","type":"module","_from":"file:0xmonaco-utils-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"dev":"tsc --watch","lint":"eslint src --ext .ts","build":"tsc -b","clean":"rm -rf dist"},"_npmUser":{"name":"besated","email":"bryan@seinetwork.io"},"_resolved":"/private/var/folders/9q/9l4nvzx50s96zwsm42t1q4800000gn/T/70528656e3e9fd713a24e93dd1d13354/0xmonaco-utils-0.1.0.tgz","_integrity":"sha512-keXThUy+C9uRUnqza0jzto86tHA+ojx50lJXTWLFuioG22zp5m4pUHe8pi6g7QyL2dyMN3hHd/iBpG4yyBAGxg==","_npmVersion":"10.9.2","description":"Utility functions for the Monaco protocol. This package provides decimal conversion utilities and logging functionality.","directories":{},"_nodeVersion":"22.15.0","dependencies":{"viem":"^2.30.6"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"5.7.3"},"_npmOperationalInternal":{"tmp":"tmp/utils_0.1.0_1756346002216_0.5222145897714754","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@0xmonaco/utils","version":"0.1.1","_id":"@0xmonaco/utils@0.1.1","maintainers":[{"name":"carsonfalcon","email":"carson@seinetwork.io"},{"name":"besated","email":"bryan@seinetwork.io"}],"dist":{"shasum":"12d15c30de348efc23738a28582a9aa1ca574f96","tarball":"https://registry.npmjs.org/@0xmonaco/utils/-/utils-0.1.1.tgz","fileCount":18,"integrity":"sha512-r2gcg14iSdSm+BnhYDSSCm6KiQWHkih7/PaaIJZPrzI0iHlnzaYJOW0lgitwfIf7/AJfx6R3KqvRf3Q3z86zPQ==","signatures":[{"sig":"MEYCIQDqv07IEY/JB6ZPF9pw5UVZc9Q3QvwRT6qhc3AQyvQTWwIhAJI0fy/5ZFhiFtm8YpbPkKWj7VI2ea4i3G6uRtjAkHtG","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8486},"main":"./dist/index.js","type":"module","_from":"file:0xmonaco-utils-0.1.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"dev":"tsc --watch","lint":"eslint src --ext .ts","build":"tsc -b","clean":"rm -rf dist"},"_npmUser":{"name":"besated","email":"bryan@seinetwork.io"},"_resolved":"/private/var/folders/9q/9l4nvzx50s96zwsm42t1q4800000gn/T/db14606044d154719dca9d7fda1088eb/0xmonaco-utils-0.1.1.tgz","_integrity":"sha512-r2gcg14iSdSm+BnhYDSSCm6KiQWHkih7/PaaIJZPrzI0iHlnzaYJOW0lgitwfIf7/AJfx6R3KqvRf3Q3z86zPQ==","_npmVersion":"10.9.2","description":"Utility functions for the Monaco protocol. This package provides decimal conversion utilities and logging functionality.","directories":{},"_nodeVersion":"22.15.0","dependencies":{"viem":"^2.30.6"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"5.7.3"},"_npmOperationalInternal":{"tmp":"tmp/utils_0.1.1_1756346442797_0.9672198124478841","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@0xmonaco/utils","version":"0.1.5","_id":"@0xmonaco/utils@0.1.5","maintainers":[{"name":"carsonfalcon","email":"carson@seinetwork.io"},{"name":"besated","email":"bryan@seinetwork.io"}],"dist":{"shasum":"ae66faca081aa852afff70cf9beb46ae84738558","tarball":"https://registry.npmjs.org/@0xmonaco/utils/-/utils-0.1.5.tgz","fileCount":18,"integrity":"sha512-lZvsHDewTvKBiUDpIDRzz7+86YBjgCjeBEuIWbnVfg0pruI+AWDnII+AxvuHtpFjPBzk2E2QIv6VLCv5+P4Ryg==","signatures":[{"sig":"MEQCIHsfd93qCvhL1ilCoizcv0UM7X7jbRGj/KVlxZD+fYLiAiBpj7sr4ZQtwchGxSZP9CcVbcn8JvkcvKqr7SOprlI2mQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8490},"main":"./dist/index.js","type":"module","_from":"file:0xmonaco-utils-0.1.5.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"dev":"tsc --watch","lint":"eslint src --ext .ts","build":"tsc -b","clean":"rm -rf dist"},"_npmUser":{"name":"besated","email":"bryan@seinetwork.io"},"_resolved":"/private/var/folders/9q/9l4nvzx50s96zwsm42t1q4800000gn/T/11ec00b5a9646d10c8b1e25261b74c29/0xmonaco-utils-0.1.5.tgz","_integrity":"sha512-lZvsHDewTvKBiUDpIDRzz7+86YBjgCjeBEuIWbnVfg0pruI+AWDnII+AxvuHtpFjPBzk2E2QIv6VLCv5+P4Ryg==","_npmVersion":"10.8.2","description":"Utility functions for the Monaco protocol. This package provides decimal conversion utilities and logging functionality.","directories":{},"_nodeVersion":"20.17.0","dependencies":{"viem":"^2.30.6"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"5.7.3"},"_npmOperationalInternal":{"tmp":"tmp/utils_0.1.5_1757369326111_0.02389941773214188","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-08-28T01:53:22.136Z","modified":"2026-05-06T16:03:34.981Z","1.0.0":"2025-07-21T18:44:29.919Z","2.0.0":"2025-08-15T20:28:49.106Z","0.1.0":"2025-08-28T01:53:22.474Z","0.1.1":"2025-08-28T02:00:43.034Z","0.1.5":"2025-09-08T22:08:46.308Z"},"description":"Utility functions for the Monaco protocol. This package provides decimal conversion utilities and logging functionality.","maintainers":[{"email":"praj@0xmonaco.com","name":"prajpitlehra"},{"email":"stubydent@gmail.com","name":"tsite"},{"email":"carson@seinetwork.io","name":"carsonfalcon"},{"email":"bryan@seinetwork.io","name":"besated"}],"readme":"# @0xmonaco/utils\n\nUtility functions for the Monaco protocol. This package provides decimal conversion utilities and logging functionality.\n\n## Installation\n\n```bash\nnpm install @0xmonaco/utils\n```\n\n## Usage\n\n### Decimal Conversion\n\nThe package provides utilities for handling token amounts in different decimal formats:\n\n```typescript\nimport {\n  convertToUniversal,\n  convertFromUniversal,\n  parseToUniversal,\n  formatFromUniversal,\n  UNIVERSAL_DECIMALS,\n} from \"@0xmonaco/utils\";\n\n// Convert between native decimals and universal 18-decimal format\nconst universalAmount = convertToUniversal(1000000n, 6); // 1 USDC (6 decimals) -> universal format\nconst nativeAmount = convertFromUniversal(universalAmount, 6); // universal format -> 1 USDC (6 decimals)\n\n// Parse human-readable amounts directly to universal format\nconst universalAmount = parseToUniversal(\"1.5\", 6); // \"1.5\" with 6 decimals -> universal format (bigint)\n\n// Format universal amounts to human-readable strings\nconst readableAmount = formatFromUniversal(universalAmount, 6); // universal format -> \"1.5\" with 6 decimals\n\n// Price conversion utilities\nconst universalPrice = convertToUniversalPrice(2000n, 6); // 2000 USDC (6 decimals) -> universal format\nconst nativePrice = convertFromUniversalPrice(universalPrice, 6); // universal format -> 2000 USDC (6 decimals)\n```\n\n### Logging\n\nA simple logging utility that provides consistent logging across the protocol:\n\n```typescript\nimport { createDefaultLogger, LogLevel } from \"@0xmonaco/utils\";\n\nconst logger = createDefaultLogger({\n  level: \"info\" as LogLevel, // 'debug' | 'info' | 'warn' | 'error'\n  debug: false, // enable/disable debug logs\n});\n\nlogger.info(\"Order placed\", { orderId: \"0x123...\", price: \"2000\", size: \"1\" });\nlogger.error(\"Order failed\", {\n  error: \"Insufficient balance\",\n  orderId: \"0x123...\",\n});\nlogger.debug(\"Market update\", { bestBid: \"1999\", bestAsk: \"2001\" });\nlogger.warn(\"High slippage detected\", { expected: \"2000\", actual: \"2010\" });\n```\n\n## API Reference\n\n### Decimal Utilities\n\n- `UNIVERSAL_DECIMALS`: The standard decimal format used by Monaco (18 decimals)\n- `convertToUniversal(amount: bigint, nativeDecimals: number): bigint`\n- `convertFromUniversal(universalAmount: bigint, nativeDecimals: number): bigint`\n- `convertToUniversalPrice(nativePrice: bigint, quoteDecimals: number): bigint`\n- `convertFromUniversalPrice(universalPrice: bigint, quoteDecimals: number): bigint`\n- `parseTokenAmount(amount: string, decimals: number): bigint`\n- `formatTokenAmount(amount: bigint, decimals: number): string`\n- `parseToUniversal(amount: string, nativeDecimals: number): bigint`\n- `formatFromUniversal(universalAmount: bigint, nativeDecimals: number): string`\n\n### Logging Utilities\n\n- `createDefaultLogger(options?: { level?: LogLevel; debug?: boolean }): Logger`\n  - `level`: 'debug' | 'info' | 'warn' | 'error' (default: 'info')\n  - `debug`: boolean to enable/disable debug logs (default: false)\n","readmeFilename":"README.md"}