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

bido-sdk-contracts

v0.1.0

Published

Contracts for Lido Finance projects. Part of [Lido JS SDK](https://github.com/lidofinance/lido-js-sdk/#readme)

Downloads

7

Readme

Contracts

Contracts for Lido Finance projects. Part of Lido JS SDK

A Contract is an abstraction of code that has been deployed to the blockchain. A Contract may be sent transactions, which will trigger its code to be run with the input of the transaction data. More details in the ethers docs.

It uses TypeChain under the hood to generate TypeScript typings for contacts.

Install

yarn add bido-sdk-contracts

Getters

Source

Each getter returns a cached Contract instance with an attached Provider and an ABI. The Provider is required to work with the network and sign transactions and the ABI contains information about methods of the contract on the ethereum side. So, the resulting instance contains all the methods supported by the contract and allows you to call them.

If a contract method requires signing a transaction, then you need a provider with Signer

getERC20Contract

Returns an instance of Contract based on ERC20 standard contract ABI.

import { getERC20Contract } from 'bido-sdk-contracts';
import { JsonRpcProvider } from '@ethersproject/providers';

const provider = new JsonRpcProvider('http://localhost:8545');
const contract = getERC20Contract(
  '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
  provider,
);

const symbol = await contract.symbol();
const decimals = await contract.decimals();

getWSTETHContract

Returns an instance of Contract based on wstETH contract ABI. Available contract methods and detailed documentation can be found here: https://docs.lido.fi/contracts/wsteth

getSTETHContract

Returns an instance of Contract based on stETH contract ABI. Available contract methods and detailed documentation can be found here: https://docs.lido.fi/contracts/lido

getLDOContract

Returns an instance of Contract based on LDO token ABI. LDO Token docs can be found here: https://docs.lido.fi/lido-dao/#ldo-token

getWithdrawalQueueContract

Returns an instance of Contract based on WithdrawalQueue contract ABI. Contract docs here: https://docs.lido.fi/contracts/withdrawal-queue-erc721

getAggregatorContract

Returns an instance of Contract based on ChainLink USD/ETH price oracle ABI. EACAggregatorProxy https://etherscan.io/address/0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419

Cache

To get another contract instance, getters have a third optional parameter cacheSeed.

Calls without cacheSeed or with the same cacheSeed return the same contracts:

const contractFirst = getERC20Contract('0x0...', provider, 1);
const contractSecond = getERC20Contract('0x0...', provider, 1);

contractFirst === contractSecond; // true

Calls with different cacheSeed return different contracts:

const contractFirst = getERC20Contract('0x0...', provider, 1);
const contractSecond = getERC20Contract('0x0...', provider, 2);

contractFirst !== contractSecond; // true

Of course, if the cacheSeed is the same, but address or provider are different the result contracts will also be different:

const contractFirst = getERC20Contract('0x1...', provider, 1);
const contractSecond = getERC20Contract('0x0...', provider, 1);

contractFirst !== contractSecond; // true, because the addresses are different