Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@generationsoftware/js-winner-calc
Advanced tools
This library calculates PoolTogether V5 winners completely in JavaScript for use in NodeJS or in a browser.
This library is installable as an NPM package using the following command:
npm i @generationsoftware/js-winner-calc
[!Important] 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.
import { computeWinners } from "@generationsoftware/js-winner-calc";
const winners = await computeWinners({
chainId: 10,
rpcUrl: "https://mainnet.optimism.io/",
prizePoolAddress: "0xF35fE10ffd0a9672d0095c435fd8767A7fe29B55",
vaultAddress: "0xa52e38a9147f5eA9E0c5547376c21c9E3F3e5e1f",
userAddresses: ["0xe24bC6c67fEF2FFe40283c1359dCE44bd19c72C4"],
})
The results will look like the following, with an array of winners and a mapping of prize tier to prize indices for each winner:
[
{
"user": "0xe24bC6c67fEF2FFe40283c1359dCE44bd19c72C4",
"prizes": {
"4": [
11
],
"5": [
451,
685,
941
]
}
}
]
Ignores the last two tiers (canary tiers) when computing wins. Enabling this will significantly speed up the calculation, but should only be used if you have no need for canary tier wins in your application.
const winners = await computeWinners({
...,
ignoreCanaries: true
})
Set 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.
const winners = await computeWinners({
...,
multicallBatchSize: 2048
})
The 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
.
const winners = await computeWinners({
...,
blockNumber: 121970626n
})
The debug
argument is an optional boolean. When set, some extra logs will be included to help debug issues.
const winners = await computeWinners({
...,
debug: true
})
npm i
npm run dev
FAQs
Calculates PoolTogether V5 winners in JavaScript.
The npm package @generationsoftware/js-winner-calc receives a total of 1,367 weekly downloads. As such, @generationsoftware/js-winner-calc popularity was classified as popular.
We found that @generationsoftware/js-winner-calc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.