
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
@leap-network/v4-utils-js
Advanced tools
Utility library for PoolTogether V4 off-chain calculations, computations and core logic.
Application | Contracts | Documentation | Draw Calculator | Frontend Client | Static Cache
The @leap-network/v4-utils-js node module package provides calculations, computations and core logic for the PoolTogether V4 protocol.
Assisting with low-level tasks like hashing addresses to generate picks and calculating the total number of prizes for a prize tier. The calculations namespaced functions are modular: consuming low-level inputs/types to parity smart contract EVM operations.
High-order operations like filtering for a users winning picks and processing chain state (draws, prizeDistributions, etc..) to analyze/predict short and long term outcomes are included in the computations namespaced functions.
🧮 Caclulations:
Arithmetic and operations to match v4-core smart contract operations:
🖥️ Computations:
Consume protocol chain state and return computed outcomes:
🏆 Core:
Gain insights into the protocol state by analyzing and encoding historical and potential chain state.
🙋 Potential Additions:
Create Issue to request new features.
Open Pull Request adhering to Contribution guidelines.
This project is available as an NPM package:
npm install @leap-network/v4-utils-js
yarn add @leap-network/v4-utils-js
The repo can be cloned from Github for contributions.
git clone https://github.com/pooltogether/v4-utils-js
Core utility functions like winningPicks(user, draw, prizeDistribution) calculate, compute and encode any EVM chain compatible transaction with the maximum number of winning picks using the input arguments.
In short, if you just need to calulcate winning picks and claim prizes the winningPicks function is for you 👋
import { Wallet } from '@ethersproject/wallet';
import { providers } from '@ethersproject/provider';
import { winningPicks, computeWinningPicks, encodeWinningPicks } from '@leap-network/v4-utils-js';
// Compute and Encode Winning Picks Seperately
const computedPicks = computeWinningPicks(user, [draw], [prizeDistribution]);
const encodePicks = encodeWinningPicks(user, computedWinningPicks);
// Compute and Encode Winning Picks Together
const computedAndEncodedWinningPicks = winningPicks(user, [draw], [prizeDistribution]);
// Send Encoded Transaction to Mainnet
const wallet = Wallet.createRandom().connect(providers.getDefaultProvider())
wallet.send(computedAndEncodedWinningPicks.encodedWinningPickIndices)
import { BigNumber } from '@ethersproject/bignumber';
import { parseEther } from '@ethersproject/units';
import { winningPicks, utils } from '@leap-network/v4-utils-js';
const user = {
address: '0x0000000000000000000000000000000000000001',
normalizedBalances: [
parseEther('0.1'), // 10% of totalSupply
],
};
const draw = {
drawId: 1,
winningRandomNumber: BigNumber.from(
'0x0000000000000000000000000000000000000000000000000000000000000001'
),
};
const prizeDistribution = {
bitRangeSize: 4,
matchCardinality: 10,
numberOfPicks: 1000,
prize: parseEther('1000'),
maxPicksPerUser: 30,
tiers: [
// Tier prizeAmount is 100% split between 10 tiers.
utils.formatTierPercentage('0.1'),
utils.formatTierPercentage('0.1'),
utils.formatTierPercentage('0.1'),
utils.formatTierPercentage('0.1'),
utils.formatTierPercentage('0.1'),
utils.formatTierPercentage('0.1'),
utils.formatTierPercentage('0.1'),
utils.formatTierPercentage('0.1'),
utils.formatTierPercentage('0.1'),
utils.formatTierPercentage('0.1'),
0,
0,
0,
0,
0,
0,
],
};
const generatedPicks = winningPicks(user, [draw], [prizeDistribution]);
/**
userAddress: string;
drawIds: number[];
winningPickIndices: BigNumber[][];
encodedWinningPickIndices: string;
* -------------------
userAddress: '0x0000000000000000000000000000000000000001',
drawIds: [1],
winningPickIndices: [[1]],
encodedWinningPickIndices: '0x000...2000...0001'
* /
The package is setup using the TSDX zero-config CLI which includes:
Minor changes have been made to extend the default configuration.
The TSDX linting configuration is overwritten to include override(s)* for:
FAQs
Utility library for PoolTogether V4 off-chain calculations, computations and core logic.
We found that @leap-network/v4-utils-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.