npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pooltogether/v4-js

v0.0.1-beta.0

Published

PoolTogether V4 JS library for general calculations and computers of the protocol state.

Downloads

3

Readme

PoolTogether V4 JS

Tests Coverage Status GPLv3 license

The v4-js module is a general purpose JS library for reading/writing to the Pooltogether V4 protocol.

Installation

This project is available as an NPM package:

npm install @pooltogether/v4-js
yarn add @pooltogether/v4-js

The repo can be cloned from Github for contributions.

git clone https://github.com/pooltogether/v4-core

Overview

Setup

Core

Config

Fetching

Utils

Getting Started

Initializing

The v4-js module must be initialized with providers and a contract list.

Current mainnet and testnet contract lists can be used via the @pooltogether/v4-pool-data NPM package

The v4-js module must be initialized before blockchain read requests be executed.

import PoolTogetherV4, { config } from 'pooltogether/v4-js';

const ptv4 = new PoolTogetherV4(config.providersMainnet, mainnetContractList)

or

import { initialize, config } from 'pooltogether/v4-js';

const ptv4 = initialize(config.providersMainnet, mainnetContractList)

Providers

Providers being passed must inherit the Provider type interface from @ethersproject/abstract-provider. In other words, ethers provider interfaces like JsonRpcProvider, InfuraProvider, FallbackProvider, etc... are usable as Provider interfaces.

const providerMainnet = ethers.getDefaultProvider('mainnet');
const providerRinkeby = new ethers.providers.InfuraProvider('rinkeby', key)
const providerMumbai = new ethers.providers.JsonRpcProvider("https://rpc-mumbai.maticvigil.com");
const providers = { 1: providerMainnet, 4: providerRinkeby, 80001: providerMumbai }

computePrizeDistribution

To compute a PrizeDistribution for a specific PrizePool/Ticket supply a Draw (from the DrawBuffer) and contract addresses for L1 PrizeTierHistory and the target Ticket contract, plus secondary Ticket contract addresses in a list.

import { computePrizeDistribution } from '../src';

const draw = {
  winningRandomNumber: BigNumber.from('21288413488180966377126236036201345909019919575750940621513526137694302720820'),
  drawId: 1,
  timestamp: 1634410924,
  beaconPeriodStartedAt: 1634324400,
  beaconPeriodSeconds: 86400,
}

const prizeTierHistory = '0xdD1cba915Be9c7a1e60c4B99DADE1FC49F67f80D'
const ticketL1 = '0xdd4d117723C257CEe402285D3aCF218E9A8236E1'
const ticketL2 = '0x6a304dFdb9f808741244b6bfEe65ca7B3b3A6076'

const results = await computePrizeDistribution(draw, prizeTierHistory, ticketL1, [ticketL2])