{"_id":"@0xfps/pmamm-js","_rev":"7-fdd5f889a46caa1b4979a3969e5d1ff3","name":"@0xfps/pmamm-js","dist-tags":{"latest":"0.0.7"},"versions":{"0.0.1":{"name":"@0xfps/pmamm-js","version":"0.0.1","keywords":["pm-amm","prediction-market","amm","pmamm","prediction-market-amm","automated-market-maker","prediction-market-automated-market-maker"],"author":{"name":"0xfps"},"license":"MIT","_id":"@0xfps/pmamm-js@0.0.1","maintainers":[{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"}],"homepage":"https://github.com/0xfps/pmamm-js#readme","bugs":{"url":"https://github.com/0xfps/pmamm-js/issues"},"dist":{"shasum":"fb58873df5e697a2a5611fdad4f35af085b1683a","tarball":"https://registry.npmjs.org/@0xfps/pmamm-js/-/pmamm-js-0.0.1.tgz","fileCount":7,"integrity":"sha512-K0tN2tbFCIJTBXV7VOEOgXtXh7ZrwtwpOrQNzLE9AdNsjZHG87vOboB+gDesAVEpEnYNLau3dIqqvxxVBFXBQQ==","signatures":[{"sig":"MEYCIQCCS/YXG05VEpW10vhAN+0B85koMSpagUmmfUemV3QZxwIhANyGhFxfQwjZcGwQY/BR9mEoNfCluef2ZgAO71TToQsj","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":47631},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"eb684cec3a2247500106e11defb61e6e5ce17d25","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"rm -rf dist && tsup"},"_npmUser":{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"},"repository":{"url":"git+https://github.com/0xfps/pmamm-js.git","type":"git"},"_npmVersion":"10.5.1","description":"A TypeScript implementation of the core functionalities of the PM-AMM Model by Paradigm @ https://www.paradigm.xyz/2024/11/pm-amm.","directories":{},"_nodeVersion":"22.0.0","dependencies":{"tsup":"^8.5.1","bisect":"^1.0.0","gaussian":"^1.3.0","@types/gaussian":"^1.2.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.2"},"_npmOperationalInternal":{"tmp":"tmp/pmamm-js_0.0.1_1775062662557_0.8972420072219356","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@0xfps/pmamm-js","version":"0.0.2","keywords":["pm-amm","prediction-market","amm","pmamm","prediction-market-amm","automated-market-maker","prediction-market-automated-market-maker"],"author":{"name":"0xfps"},"license":"MIT","_id":"@0xfps/pmamm-js@0.0.2","maintainers":[{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"}],"homepage":"https://github.com/0xfps/pmamm-js#readme","bugs":{"url":"https://github.com/0xfps/pmamm-js/issues"},"dist":{"shasum":"8ba3d0fd1b43ba6522e6203f35aee56db60bf48e","tarball":"https://registry.npmjs.org/@0xfps/pmamm-js/-/pmamm-js-0.0.2.tgz","fileCount":8,"integrity":"sha512-0kBZaeS8ZeHeMiJVOVpkYMXE9xbGUFj9lftPFMtssg0mWZ9DpipD3rddj9naTjmX2d7L6cQ6NbWB+0g+1dcsgA==","signatures":[{"sig":"MEQCIFrPfq+KEreybvW0KpVIzX9K6MZDlkaxKpQ0gX2zXAVpAiAGXyOre3IY8Ot1DtfLC+D6RSgMuyg/YPbiELhtCJrZBw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52080},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"c61c32b0ab5068d688104db4bf4d5475d34de290","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"rm -rf dist && tsup"},"_npmUser":{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"},"repository":{"url":"git+https://github.com/0xfps/pmamm-js.git","type":"git"},"_npmVersion":"10.5.1","description":"A TypeScript implementation of the core functionalities of the PM-AMM Model by Paradigm @ https://www.paradigm.xyz/2024/11/pm-amm.","directories":{},"_nodeVersion":"22.0.0","dependencies":{"tsup":"^8.5.1","bisect":"^1.0.0","gaussian":"^1.3.0","@types/gaussian":"^1.2.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.2"},"_npmOperationalInternal":{"tmp":"tmp/pmamm-js_0.0.2_1775071845548_0.46229473298266677","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@0xfps/pmamm-js","version":"0.0.3","keywords":["pm-amm","prediction-market","amm","pmamm","prediction-market-amm","automated-market-maker","prediction-market-automated-market-maker"],"author":{"name":"0xfps"},"license":"MIT","_id":"@0xfps/pmamm-js@0.0.3","maintainers":[{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"}],"homepage":"https://github.com/0xfps/pmamm-js#readme","bugs":{"url":"https://github.com/0xfps/pmamm-js/issues"},"dist":{"shasum":"25f2289577029b7a0e44568b52ca9834151991b8","tarball":"https://registry.npmjs.org/@0xfps/pmamm-js/-/pmamm-js-0.0.3.tgz","fileCount":8,"integrity":"sha512-NGvdt0q5IlPben336hg25nnE17YSHqYmsXNPqEd9da2K680e/VbpbQnYbh5EBCSvXtKQZ8d1zGA77y5UbozqtQ==","signatures":[{"sig":"MEYCIQC51uR9ei+I/tR/ueqftya4qksFZoqOfwniVGMDiEIsJgIhAMDTo/DdCJIi3mx4uTifoXjl+FtMVF/2aYA33Tksrmdq","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53048},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"6509a678c73ba7b7e1d0e4febd8dfc268722d7e1","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"rm -rf dist && tsup"},"_npmUser":{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"},"repository":{"url":"git+https://github.com/0xfps/pmamm-js.git","type":"git"},"_npmVersion":"10.5.1","description":"A TypeScript implementation of the core functionalities of the PM-AMM Model by Paradigm @ https://www.paradigm.xyz/2024/11/pm-amm.","directories":{},"_nodeVersion":"22.0.0","dependencies":{"tsup":"^8.5.1","bisect":"^1.0.0","gaussian":"^1.3.0","@types/gaussian":"^1.2.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.2"},"_npmOperationalInternal":{"tmp":"tmp/pmamm-js_0.0.3_1775112854867_0.8122900663199146","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@0xfps/pmamm-js","version":"0.0.4","keywords":["pm-amm","prediction-market","amm","pmamm","prediction-market-amm","automated-market-maker","prediction-market-automated-market-maker"],"author":{"name":"0xfps"},"license":"MIT","_id":"@0xfps/pmamm-js@0.0.4","maintainers":[{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"}],"homepage":"https://github.com/0xfps/pmamm-js#readme","bugs":{"url":"https://github.com/0xfps/pmamm-js/issues"},"dist":{"shasum":"06f12a65bd22de815cda967962359f34a6da462d","tarball":"https://registry.npmjs.org/@0xfps/pmamm-js/-/pmamm-js-0.0.4.tgz","fileCount":8,"integrity":"sha512-PbV4n+T0ZKc17srw3h3OFS8sO7NCZsM0EquOfgpEQK5lElM9PnG7KZ7X74NHt7cLpQBYoD+5yzUFC6SHxSR9Uw==","signatures":[{"sig":"MEQCIF32MEsdLvF/YeX+Euzq3RC9F654+YK5dgLA1TcSoUeNAiB2RLWbgwIXrDpKg6WcPUhuomEb2X60eN974pV1EBQwqA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53324},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"7e16f84d3a0a94f440cefd643f090467dfe5fe41","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"rm -rf dist && tsup"},"_npmUser":{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"},"repository":{"url":"git+https://github.com/0xfps/pmamm-js.git","type":"git"},"_npmVersion":"10.5.1","description":"A TypeScript implementation of the core functionalities of the PM-AMM Model by Paradigm @ https://www.paradigm.xyz/2024/11/pm-amm.","directories":{},"_nodeVersion":"22.0.0","dependencies":{"tsup":"^8.5.1","bisect":"^1.0.0","gaussian":"^1.3.0","@types/gaussian":"^1.2.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.2"},"_npmOperationalInternal":{"tmp":"tmp/pmamm-js_0.0.4_1775113280281_0.4367864813501834","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@0xfps/pmamm-js","version":"0.0.5","keywords":["pm-amm","prediction-market","amm","pmamm","prediction-market-amm","automated-market-maker","prediction-market-automated-market-maker"],"author":{"name":"0xfps"},"license":"MIT","_id":"@0xfps/pmamm-js@0.0.5","maintainers":[{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"}],"homepage":"https://github.com/0xfps/pmamm-js#readme","bugs":{"url":"https://github.com/0xfps/pmamm-js/issues"},"dist":{"shasum":"7f2cf6bb0884e525ee9fd9e66db39a114858f520","tarball":"https://registry.npmjs.org/@0xfps/pmamm-js/-/pmamm-js-0.0.5.tgz","fileCount":8,"integrity":"sha512-JILnxPOW8CgqRiNDYxsrPezf7//Nez7AE/k9vABeDHpVvaShvjwtWxyzJCTsb/la2de8V6IOOWdVl8JeXXkQxQ==","signatures":[{"sig":"MEUCIDygg8yJcBLAAlCgJ0zIZ3/A3/Y4fuQadcLfLKSVQSWZAiEAg1JJBAI390Zl+Hh61Cc2XDTgCUAcBtmOPo7rLk8UTu0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54978},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"e5204824fc250e161d34fe5dd5205b1274343146","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"rm -rf dist && tsup"},"_npmUser":{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"},"repository":{"url":"git+https://github.com/0xfps/pmamm-js.git","type":"git"},"_npmVersion":"10.5.1","description":"A TypeScript implementation of the core functionalities of the PM-AMM Model by Paradigm @ https://www.paradigm.xyz/2024/11/pm-amm.","directories":{},"_nodeVersion":"22.0.0","dependencies":{"tsup":"^8.5.1","bisect":"^1.0.0","gaussian":"^1.3.0","@types/gaussian":"^1.2.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.2"},"_npmOperationalInternal":{"tmp":"tmp/pmamm-js_0.0.5_1775289137198_0.27705538492897563","host":"s3://npm-registry-packages-npm-production"}},"0.0.6":{"name":"@0xfps/pmamm-js","version":"0.0.6","keywords":["pm-amm","prediction-market","amm","pmamm","prediction-market-amm","automated-market-maker","prediction-market-automated-market-maker"],"author":{"name":"0xfps"},"license":"MIT","_id":"@0xfps/pmamm-js@0.0.6","maintainers":[{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"}],"homepage":"https://github.com/0xfps/pmamm-js#readme","bugs":{"url":"https://github.com/0xfps/pmamm-js/issues"},"dist":{"shasum":"b52f40f02e679ee07ca1f5156f157695206c2aec","tarball":"https://registry.npmjs.org/@0xfps/pmamm-js/-/pmamm-js-0.0.6.tgz","fileCount":8,"integrity":"sha512-1koP9kfAp/vO/PUo/Y6WVjt0aleadtDhOvOJj3ZZkCcD5JAKA8z6j+Ixf2gM4K4xo2dIF+TuwWWxYeWfLhh0bg==","signatures":[{"sig":"MEUCIHpjOtbMkK5Q5RpWfBSmCLhsxTk69lfjONiFN6fG/LRTAiEA+bUZEzbkxA0ZWnzMfGP/k5YGNXcEXfdzyQkEbMhbE7M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54992},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"19ac8e1012e79c2125b8ecc5f4dc2fcb4e988c3a","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"rm -rf dist && tsup"},"_npmUser":{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"},"repository":{"url":"git+https://github.com/0xfps/pmamm-js.git","type":"git"},"_npmVersion":"10.5.1","description":"A TypeScript implementation of the core functionalities of the PM-AMM Model by Paradigm @ https://www.paradigm.xyz/2024/11/pm-amm.","directories":{},"_nodeVersion":"22.0.0","dependencies":{"tsup":"^8.5.1","bisect":"^1.0.0","gaussian":"^1.3.0","@types/gaussian":"^1.2.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.2"},"_npmOperationalInternal":{"tmp":"tmp/pmamm-js_0.0.6_1775312953506_0.2378352259836931","host":"s3://npm-registry-packages-npm-production"}},"0.0.7":{"name":"@0xfps/pmamm-js","version":"0.0.7","description":"A TypeScript implementation of the core functionalities of the PM-AMM Model by Paradigm @ https://www.paradigm.xyz/2024/11/pm-amm.","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","scripts":{"test":"jest","build":"jest && rm -rf dist && tsup","publish":"npm publish --access=public"},"repository":{"type":"git","url":"git+https://github.com/0xfps/pmamm-js.git"},"keywords":["pm-amm","prediction-market","amm","pmamm","prediction-market-amm","automated-market-maker","prediction-market-automated-market-maker"],"author":{"name":"0xfps"},"license":"MIT","bugs":{"url":"https://github.com/0xfps/pmamm-js/issues"},"homepage":"https://github.com/0xfps/pmamm-js#readme","dependencies":{"@types/gaussian":"^1.2.2","gaussian":"^1.3.0","tsup":"^8.5.1"},"devDependencies":{"@types/jest":"^30.0.0","jest":"^30.3.0","ts-jest":"^29.4.9","typescript":"^6.0.2"},"_id":"@0xfps/pmamm-js@0.0.7","gitHead":"bc7695a897b9b93f24cc5a96a87fca4a4b715493","_nodeVersion":"22.0.0","_npmVersion":"10.5.1","dist":{"integrity":"sha512-/ORzfghWygaYoCYVBe9yvG5TG8z7Fajbk90qc1kNeEnRMSgESQMUoU4bqrsv1ZGQr5PVx59bo3H1pMjnC6KGuQ==","shasum":"373ef9302f1d9f9439e1481b3aee6eb758a60dde","tarball":"https://registry.npmjs.org/@0xfps/pmamm-js/-/pmamm-js-0.0.7.tgz","fileCount":8,"unpackedSize":57400,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBfNLtYb33wTMpD5u65CFTY/TsMFAWPBfANdP4RYgjADAiEAvHUn+Ba2HWxTnK3kW6srJakg/78TcRaIRXT5YX9/v/c="}]},"_npmUser":{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"},"directories":{},"maintainers":[{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pmamm-js_0.0.7_1775465810043_0.024004637462505363"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-01T16:57:42.476Z","modified":"2026-04-06T08:56:50.288Z","0.0.1":"2026-04-01T16:57:42.828Z","0.0.2":"2026-04-01T19:30:45.747Z","0.0.3":"2026-04-02T06:54:15.009Z","0.0.4":"2026-04-02T07:01:20.427Z","0.0.5":"2026-04-04T07:52:17.384Z","0.0.6":"2026-04-04T14:29:13.663Z","0.0.7":"2026-04-06T08:56:50.183Z"},"bugs":{"url":"https://github.com/0xfps/pmamm-js/issues"},"author":{"name":"0xfps"},"license":"MIT","homepage":"https://github.com/0xfps/pmamm-js#readme","keywords":["pm-amm","prediction-market","amm","pmamm","prediction-market-amm","automated-market-maker","prediction-market-automated-market-maker"],"repository":{"type":"git","url":"git+https://github.com/0xfps/pmamm-js.git"},"description":"A TypeScript implementation of the core functionalities of the PM-AMM Model by Paradigm @ https://www.paradigm.xyz/2024/11/pm-amm.","maintainers":[{"name":"0xfps","email":"anthony.nnaemeka.umeh@gmail.com"}],"readme":"# PM-AMM (Prediction Market Automated Market Maker)\n#### `pmamm-js`\n\nThis package provides a practical implementation of the prediction market automated market maker introduced by Paradigm, commonly referred to as the [pm-AMM](https://www.paradigm.xyz/2024/11/pm-amm). The pm-AMM is designed specifically for outcome tokens; assets that resolve to fixed payoffs (e.g., $1 or $0), and is derived from a probabilistic model known as Gaussian Score Dynamics. Unlike traditional AMMs such as constant product or LMSR, this design enforces a uniform loss-vs-rebalancing (LVR) profile, meaning liquidity providers incur losses at a rate proportional to pool value regardless of price, while concentrating liquidity around the most informative probability region (near 50%).\n\nBeyond the core invariant, the package covers the full set of mechanics required to work with a pm-AMM in practice. It includes utilities for modeling price dynamics over time, computing price from reserves and inversely deriving reserves from a target price, and simulating trades to determine resulting costs and updated pool states. Users can simulate buying or selling either `YES` or `NO` tokens, with accurate computation of post-trade reserves and average execution cost. Additionally, the package incorporates a port of the reference Python simulator, enabling numerical experimentation and validation, along with a small set of helper utilities to streamline integration and testing workflows.\n\nNote that the `X` token represents the `YES` outcome, while the `Y` token represents the `NO` outcome.\n\n## How To Install\n\n```bash\nnpm install @0xfps/pmamm-js\n```\n\n\n## Important Types\n\n### `Reserves`\n```typescript\ntype Reserves = {\n    x: number,  // $YES.\n    y: number   // $NO.\n}\n```\nShows the number of shares available for the `YES` and `NO` tokens.\n\n### `AfterTrade`\n```typescript\ntype AfterTrade = {\n    oldXReserve: number,\n    oldYReserve: number,\n    oldPrice: number,\n    newXReserve: number,\n    newYReserve: number,\n    newPrice: number\n    cost: number,\n    averageCost: number,\n}\n```\nShows the metadata of a the result of the purchase or sale of a certain number of shares.\n\n### `MarketTime`\n```typescript\ntype type MarketTime = {\n    startTime: number,\n    currentTime: number,\n    endTime: number\n}\n```\nEvery market runs within a certain time. This shows the time data, the start time of the market, the end time of the market and the current time, ideally, when the trade is to be done.\n\n### `Order`\n```typescript\ntype Order = {\n    shares: number,\n    isBuy: boolean,\n    price: number,\n    marketTime: MarketTime\n}\n```\nContains the details of the purchase or sale of a certain number of shares. It's token agnostic. There are separate functions for the purchase and sale of the `YES` and `NO` tokens.\n\n## Usage\n\n### `getNewReservesDataAfterXTrade`\n```typescript\nfunction getNewReservesDataAfterXTrade(order: Order): AfterTrade\n```\n\nReturns the market data that would be in place after a successful execution of the purchase or sale of `X` shares (`YES` shares).\n\n### `getNewReservesDataAfterYTrade`\n```typescript\nfunction getNewReservesDataAfterYTrade(order: Order): AfterTrade\n```\n\nReturns the market data that would be in place after a successful execution of the purchase or sale of the `Y` shares (`NO` shares).\n\n### `getPriceFromReseves`\n```typescript\nfunction getPriceFromReseves(reserves: Reserves, marketTime: MarketTime): number\n```\n\nReturns the price of the `X` token from the reserves of `X` and `Y` using the market time. To get the price of `Y`, simply do:\n```typescript\nconst yPrice = 1 - getPriceFromReseves(reserves, marketTime)\n```\n\n### `getReservesFromPrice`\n```typescript\nfunction getReservesFromPrice(price: number, marketTime: MarketTime): Reserves\n```\n\nReturns the quantity of `X` and `Y` shares available using the price and the market time.\n\n### `getEffectiveLiquidity`\n```typescript\nfunction getEffectiveLiquidity(marketTime: MarketTime): number\n```\n\nReturns effective liquidity from liquidity factor. Leff = L(√(T - t)). Where T = End time, market closing time and t = current time.\n\n### `invariant`\n```typescript\nfunction invariant(x: number, y: number, Leff: number): number\n```\n\nGiven a particular number of `X` and `Y` shares and an effective liquidity, `Leff`, this function should return `0` or a number infinitesimally close to `0`. This validates that the `X` and `Y` share amounts are valid reserves for the PM-AMM. It's the `XY = K` of PM-AMMs.\n\n## Acknowledgements\n- [pm-AMM: A Uniform AMM for Prediction Markets](https://www.paradigm.xyz/2024/11/pm-amm) by [Paradigm](https://www.paradigm.xyz/).\n- [pm-amm-simulator](https://github.com/iagodemacedo/pm-amm-simulator) by [iagodemacedo](https://github.com/iagodemacedo).","readmeFilename":"README.md"}