Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@generationsoftware/hyperstructure-client-js
Advanced tools
Lightweight library for interacting with PoolTogether contracts
Client Monorepo | Documentation | Prize Pool Contract | Vault Contract
A JS client library for wrapping Viem contracts and providing simple, unopinionated interfaces for interacting with the protocol.
The library exports the following classes to interact with different aspects of the protocol, including reading and writing onchain data:
PrizePool
Vault
Vaults
Useful utilities and types are also exported from internal packages. See the utilities or types packages for more info.
This library is available as an NPM package:
npm install @generationsoftware/hyperstructure-client-js
or
pnpm install @generationsoftware/hyperstructure-client-js
or
yarn add @generationsoftware/hyperstructure-client-js
A PrizePool
is an interface to interact with a prize pool contract, which is responsible for aggregating contributions from all vaults and awarding prizes.
To create an instance of a PrizePool
, you will need:
If you'd like to use any write methods, you must also provide a Viem wallet client.
import { PrizePool } from '@generationsoftware/hyperstructure-client-js'
import { createPublicClient, createWalletClient } from 'viem'
// Viem clients
const publicClient = createPublicClient({ ... })
const walletClient = createWalletClient({ ... })
// Optional parameters
const options = {
walletClient: walletClient,
prizeTokenAddress: '0x456...',
drawPeriodInSeconds: 86_400,
tierShares: 100
}
// Initializing PrizePool
const prizePool = new PrizePool(1, '0x123...', publicClient, options)
A Vault
is an interface to interact with a vault contract, which is an ERC 4626 wrapper around any yield source, responsible for deposits and withdrawals.
To create an instance of a Vault
, you will need:
If you'd like to use any write methods, you must also provide a Viem wallet client.
import { Vault } from '@generationsoftware/hyperstructure-client-js'
import { createPublicClient, createWalletClient } from 'viem'
// Viem clients
const publicClient = createPublicClient({ ... })
const walletClient = createWalletClient({ ... })
// Optional parameters
const options = {
walletClient: walletClient,
decimals: 18,
tokenAddress: '0x456...',
name: 'Really Cool Vault',
logoURI: 'https://...',
tokenLogoURI: 'https://...'
}
// Initializing Vault
const vault = new Vault(1, '0x123...', publicClient, options)
A Vaults
is an read-only interface for multiple vault contracts. It is meant to take in all vaults in a VaultList
and create Vault
objects for each of them, allowing for more efficient aggregate queries.
To create an instance of Vaults
, you will need:
VaultInfo
data for each of the vaults in the VaultList
.See the typing of a VaultList
here.
import { Vaults } from '@generationsoftware/hyperstructure-client-js'
// VaultList
const vaultList = {
name: 'Amazing Vault List',
version: { ... },
timestamp: '...',
tokens: [{ ... }]
}
// Viem public clients
const publicClients = {
1: createPublicClient({ ... }),
10: createPublicClient({ ... }),
42161: createPublicClient({ ... })
}
// Initializing Vaults
const vaults = new Vaults(vaultList.tokens, publicClients)
const tokenData = await prizePool.getPrizeTokenData()
const lastDrawId = await prizePool.getLastAwardedDrawId()
const allPrizeInfo = await prizePool.getAllPrizeInfo()
NOTE: Since this is a write function, a wallet client is required when initializing PrizePool
.
const userAddress = '0x123...'
const prizeTier = 0
const txHash = await prizePool.claimPrize(userAddress, prizeTier)
const tokenData = await vault.getTokenData() // Deposited asset
const shareData = await vault.getShareData() // Receipt token
const userAddress = '0x123...'
const tokenBalance = await vault.getUserTokenBalance(userAddress)
const shareBalance = await vault.getUserShareBalance(userAddress)
const totalTokenBalance = await vault.getTotalTokenBalance()
NOTE: Since this is a write function, a wallet client is required when initializing Vault
.
const amount = 123456789n // Bigint value w/ decimals
const txHash = await vault.deposit(amount)
NOTE: Since this is a write function, a wallet client is required when initializing Vault
.
NOTE: You can withdraw
a token amount, but it is generally better to redeem
a share amount.
const amount = 123456789n // Bigint value w/ decimals
const txHash = await vault.redeem(amount)
const allTokenData = await vaults.getTokenData()
const allShareData = await vaults.getShareData()
const userAddress = '0x123...'
const allTokenBalances = await vaults.getUserTokenBalances(userAddress)
const allShareBalances = await vaults.getUserShareBalances(userAddress)
FAQs
Lightweight library for interacting with PoolTogether contracts
The npm package @generationsoftware/hyperstructure-client-js receives a total of 28 weekly downloads. As such, @generationsoftware/hyperstructure-client-js popularity was classified as not popular.
We found that @generationsoftware/hyperstructure-client-js 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.