{"id":20030777,"url":"https://github.com/generationsoftware/js-winner-calc","last_synced_at":"2026-05-03T11:31:33.732Z","repository":{"id":246909108,"uuid":"824651458","full_name":"GenerationSoftware/js-winner-calc","owner":"GenerationSoftware","description":"Calculates PoolTogether V5 winners in NodeJS or in a browser.","archived":false,"fork":false,"pushed_at":"2024-09-06T00:09:39.000Z","size":133,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T17:47:21.011Z","etag":null,"topics":["javascript","pooltogether"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GenerationSoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-05T15:46:58.000Z","updated_at":"2024-09-06T00:09:42.000Z","dependencies_parsed_at":"2024-07-10T04:13:57.587Z","dependency_job_id":"279cdcfd-bb8d-4979-b3b0-411bed23ebd6","html_url":"https://github.com/GenerationSoftware/js-winner-calc","commit_stats":null,"previous_names":["generationsoftware/tevm-winner-calc","generationsoftware/js-winner-calc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenerationSoftware%2Fjs-winner-calc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenerationSoftware%2Fjs-winner-calc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenerationSoftware%2Fjs-winner-calc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenerationSoftware%2Fjs-winner-calc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GenerationSoftware","download_url":"https://codeload.github.com/GenerationSoftware/js-winner-calc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241461901,"owners_count":19966773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","pooltogether"],"created_at":"2024-11-13T09:28:15.554Z","updated_at":"2026-05-03T11:31:33.726Z","avatar_url":"https://github.com/GenerationSoftware.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PoolTogether JS Winner Calculator\n\nThis library calculates PoolTogether V5 winners completely in JavaScript for use in NodeJS or in a browser.\n\n## Installation\n\nThis library is installable as an NPM package using the following command:\n\n```\nnpm i @generationsoftware/js-winner-calc\n```\n\n## How to Calculate Winners for a Vault\n\n\u003e [!Important]\n\u003e This script batches RPC queries for a given vault, so you'll need to run it for each vault that you want to check prizes for. If you are querying results for many users, it is recommended to use a private RPC endpoint to avoid public rate limits.\n\n```js\nimport { computeWinners } from \"@generationsoftware/js-winner-calc\";\n\nconst winners = await computeWinners({\n  chainId: 10,\n  rpcUrl: \"https://mainnet.optimism.io/\",\n  prizePoolAddress: \"0xF35fE10ffd0a9672d0095c435fd8767A7fe29B55\",\n  vaultAddress: \"0xa52e38a9147f5eA9E0c5547376c21c9E3F3e5e1f\",\n  userAddresses: [\"0xe24bC6c67fEF2FFe40283c1359dCE44bd19c72C4\"],\n})\n```\n\nThe results will look like the following, with an array of **winners** and a mapping of **prize tier** to **prize indices** for each winner:\n\n```json\n[\n  {\n    \"user\": \"0xe24bC6c67fEF2FFe40283c1359dCE44bd19c72C4\",\n    \"prizes\": {\n      \"4\": [\n        11\n      ],\n      \"5\": [\n        451,\n        685,\n        941\n      ]\n    }\n  }\n]\n```\n\n## Optional Arguments\n\n### prizeTiers\n\nEnables the calculation to be limited to only the listed prize tiers. Calculating wins for lower tiers only can significantly speed up the calculation. If this list is not passed to the function call, all active tiers will be computed.\n\n\u003e [!Note]\n\u003e There is no validation of the tier numbers provided.\n\n#### Example:\n\n```js\nconst winners = await computeWinners({\n  ...,\n  prizeTiers: [0,1,5]\n})\n```\n\n--------------------------------------------------------------------------------\n\n### multicallBatchSize\n\nSet the `multicallBatchSize` argument in the input json file to limit multicall size (in bytes) for RPC calls. Different RPCs may have harsher limits than others.\n\n#### Example:\n\n```js\nconst winners = await computeWinners({\n  ...,\n  multicallBatchSize: 2048\n})\n```\n\n--------------------------------------------------------------------------------\n\n### multicallAddress\n\nSet the `multicallAddress` argument in the input json file to use a custom Multicall contract for RPC calls.\n\n#### Example:\n\n```js\nconst winners = await computeWinners({\n  ...,\n  multicallAddress: '0xcA11bde05977b3631167028862bE2a173976CA11' // Gnosis Chiado testnet Multicall3 address\n})\n```\n\n--------------------------------------------------------------------------------\n\n### accountTwabBatchSize\n\nThe `accountTwabBatchSize` optional value sets the number of account TWAB values to query per batch RPC call (default: 1024). If you are experiencing failed TWAB requests, this value may be set too high if your RPC provider can't handle large payloads, or it may be set too low if you are running into rate limits with your RPC provider.\n\n#### Example:\n\n```js\nconst winners = await computeWinners({\n  ...,\n  accountTwabBatchSize: 1024 // Each TWAB batch query will contain up to 1024 account addresses\n})\n```\n\n--------------------------------------------------------------------------------\n\n### blockNumber\n\nThe `blockNumber` argument can be set to run the script at a specific block number instead of the current block. Must be either a number or string that can be parsed into a `BigInt`.\n\n#### Example:\n\n```js\nconst winners = await computeWinners({\n  ...,\n  blockNumber: 121970626n\n})\n```\n\n--------------------------------------------------------------------------------\n\n### debug\n\nThe `debug` argument is an optional boolean. When set, some extra logs will be included to help debug issues.\n\n#### Example:\n\n```js\nconst winners = await computeWinners({\n  ...,\n  debug: true\n})\n```\n\n## Local Development\n\n1. clone this repo\n3. run `npm i`\n4. run `npm run dev`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenerationsoftware%2Fjs-winner-calc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenerationsoftware%2Fjs-winner-calc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenerationsoftware%2Fjs-winner-calc/lists"}