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

vesper-lib

v1.0.0

Published

Vesper JavaScript library

Downloads

161

Readme

vesper-lib

Vesper JavaScript library.

This library is used by the Vesper app and several supporting services. Once instantiated, it exposes methods to operate with the Vesper contracts, query information, deposit, withdraw, claim VSP and more.

Installation

npm install vesper-lib

Usage

const createVesper = require('vesper-lib')
const Web3 = require('web3')

const web3 = new Web3()

const vesper = createVesper(web3)

vesper.getPools().then(console.log)
// Prints information on all the pools

vesper.vETH.getBalance(myAccount).then(console.log)
// Prints my vETH balance

API

createVesper(web3, options)

Creates an instance of the Vesper lib using the provided Web3 instance. Then the lib instance can be used to operate with the contracts.

Arguments

  • web3 (object): A Web3 instance.
  • options (object): An object with options for the library.
    • from ({string}): The address used to send transactions from.
    • metadata ({string}): Vesper metadata overrides for testing.
    • overestimation ({number}): Gas overestimation factor.
    • stages ({string[]}): List of pools to instantiate or ['all'].

Returns

A vesper library instance.

vesper.pool.method(params)

All the pool operations are exposed in the vesper instance and grouped by pool.

Selectors

  • pool: The name of the pool (i.e. vETH) or the address (i.e. 0x103c...).
  • method: Any of the methods available in the pool. See below.
  • params: The params of the corresponding method. See below.

Read methods

  • getAddress(): Gets the address of the pool contract.

  • getAssetAddress(): Gets the address of the deposit asset contract.

  • getStrategyAddress(): Gets the address of the strategy contract.

  • getPoolRewardsAddress(): Gets the address of the PoolRewards contract.

  • getBalance(): Gets the user's balance of pool tokens.

  • getAssetBalance(): Gets the user's balance of deposit assets.

  • getDepositedBalance(): Gets the user's balance of pool tokens in deposit asset.

  • getWithdrawTimelock(): Gets the time when the withdraw lock will expire in ms or 0 if unlocked.

  • hasVspRewards(): Checks if the pool has VSP rewards.

  • getVspRewardsRate(): Gets the VSP rewards rate in VSP/sec.

  • getClaimableVsp(): Gets the balance of claimable VSP.

  • getTokenValue(): Gets the value of a pool token in deposit assets.

  • getTotalSupply(): Gets the total supply of pool tokens.

  • getValueLocked(): Gets the value locked in the pool in USDC.

  • getInterestEarned(): Gets the interest earned in deposit asset since the last rebalance.

  • getInterestFee(): Gets the interes fee.

  • getWithdrawFee(): Gets the withdraw fee.

Returns

A Promise with the requested data.

Transaction methods

  • deposit(amount, transactionOptions): Deposits assets in the pool.
  • withdraw(amount, transactionOptions): Withdraws deposit assets from the pool.
  • claimVsp(transactionOptions): Claims all claimable VSP in the pool.
Arguments
  • ammount (string): The amount of deposit assets to operate.
  • transactionOptions (object): The standard web3 transaction options.
Returns

A Promise that resolves to an object summary of the operation. The returned properties of the summary can be:

  • sent (string): The amount of tokens sent.
  • fees (string): The transaction fees in ETH.
  • received (string): The amount of tokens received.
  • decimals (string): The decimals of the received token.
  • raw (object[]): An array of all the { transaction, receipt } tuples.
  • status (boolean): Whether the operation succeded.

End-to-end testing

The following environment variables control how the tests run:

  • BASE_NODE_URL is the URL of the node used to fork the chain (see below). Must be an archive node.
  • NODE_URL is the URL used to communicate with the network.
  • MNEMONIC is the 12-word mnemonic used to sign transactions.
  • ACCOUNT is the BIP44 account number used to derive the signing keys from the mnemonic. Defaults to 0.

For convenience, define these environment variables in a .env file. Then run the end-to-end tests:

npm run test:e2e

License

MIT